Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JAVA Prometheus Pushgateway客户端推送具有多个标签(键值)的非类型度量?_Prometheus_Client Library_Prometheus Pushgateway - Fatal编程技术网

如何使用JAVA Prometheus Pushgateway客户端推送具有多个标签(键值)的非类型度量?

如何使用JAVA Prometheus Pushgateway客户端推送具有多个标签(键值)的非类型度量?,prometheus,client-library,prometheus-pushgateway,Prometheus,Client Library,Prometheus Pushgateway,我想使用java PushGateway客户端推送度量 示例推送网关URL pushgateway.com:9091/metrics/job/job\u name 样本指标 度量值{instance=“i1”,label1=“l1”,label2=“l2”,label3=“l3”,label4=“l4”} 有谁能给我提供一个代码片段,用它将上述指标推送到Pushgateway中 注意 我们有20K个临时实例运行该应用程序,因此决定使用Pushgateway。来自以下官方文档: 要使用分组键jo

我想使用java PushGateway客户端推送度量

示例推送网关URL pushgateway.com:9091/metrics/job/job\u name

样本指标 度量值{instance=“i1”,label1=“l1”,label2=“l2”,label3=“l3”,label4=“l4”}

有谁能给我提供一个代码片段,用它将上述指标推送到Pushgateway中

注意
我们有20K个临时实例运行该应用程序,因此决定使用Pushgateway。

来自以下官方文档:

  • 要使用分组键
    job=“directory\u cleaner”
    path=“/var/tmp”
    ,以下路径将不起作用:
相反,对标签值使用base64 URL安全编码,并通过在标签名称后面加上
@base64
来标记它:

/metrics/job/directory_cleaner/path@base64/L3Zhci90bXA
下面是从存储在
Map groupingKey
中的多个键值对生成
url
的示例:

String url=gatewayBaseURL;
if(作业包含(“/”){
url+=”job@base64/“+base64url(作业);
}否则{
url+=“作业/”+urlcoder.encode(作业,“UTF-8”);
}
if(groupingKey!=null){
对于(Map.Entry:groupingKey.entrySet()){
if(entry.getValue()包含(“/”){
url+=“/”+entry.getKey()+“@base64/”+base64url(entry.getValue());
}否则{
url+=“/”+entry.getKey()+“/”+urlcoder.encode(entry.getValue(),“UTF-8”);
}
}
}
HttpURLConnection=connectionFactory.create(url);

/metrics/job/directory_cleaner/path@base64/L3Zhci90bXA