如何将spring boot actuator指标导出到日志文件

时间:2018-02-02 20:13:32

标签: spring-boot spring-boot-actuator

如何将执行机构指标转储到日志文件。

尝试使用metricsEndpointMetricReader但无法获得任何结果。 任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

您可以自动装配所有PublicMetrics,并将结果提取到地图并进行记录。

def loss2(logits,labels):
    logit_t = tf.transpose(logits)

    logits2 = tf.multiply(logits,logits)
    sum1 = tf.reduce_sum(logits2,1)
    sum1_t = tf.transpose(sum1)
    product = tf.matmul(logits,logit_t)
    sum_2 = sum1 + sum1_t
    H = sum_2 - product

    mean = tf.reduce_mean(H)
    H = tf.exp(-H/mean+1e-10) 

    kv,ki = tf.nn.top_k(H,5)
    kmin = tf.reduce_min(kv,axis = 1)[:,None]

    new_mat = tf.where(H<kmin,tf.zeros_like(H),tf.ones_like(H))
    H_top = tf.multiply(H,new_mat)
    H_top_t = tf.transpose(H_top)
    #H_top_t = tf.transpose(H_top)
    H_top_sum = tf.reduce_sum(H_top,1)
    H_top_de = tf.diag(H_top_sum)
    H_top_deinv = tf.diag(1/H_top_sum)

    w = [0.6,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04]
    #w = [0.6,0.04,0.04,0.04,0.04,0.04,0.04,0.04]
    w = tf.convert_to_tensor(w)
    W = tf.diag(w)
    H_top_devec = tf.matmul(H_top,W)
    H_top_devec = tf.reduce_sum(H_top_devec,1)
    H_top_dvinv2 = tf.sqrt(H_top_devec)
    H_top_dvinv2 = tf.diag(H_top_dvinv2)

    theta = tf.matmul(H_top_dvinv2,H_top_t)
    theta = tf.matmul(theta,W)
    theta = tf.matmul(theta,H_top_deinv)
    theta = tf.matmul(theta,H_top)
    theta = tf.matmul(theta,H_top_dvinv2)

    temp2 = tf.ones_like(w)
    f = 0.01*(tf.diag(temp2)-theta)

    y = [[1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]]
    #y=[[1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]]
    y = tf.convert_to_tensor(y)
    y = tf.transpose(y)
    f = tf.matrix_inverse(f)
    f = tf.matmul(f,y)
    f_t = tf.transpose(f)
    omiga = tf.matmul(f_t,(tf.ones_like(theta)-theta))
    omiga = tf.matmul(omiga,f)

    loss1 = omiga+0.01*tf.square(f-y)
    return loss1