Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.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
Node.js 无法在普罗米修斯中推送度量_Node.js_Prometheus - Fatal编程技术网

Node.js 无法在普罗米修斯中推送度量

Node.js 无法在普罗米修斯中推送度量,node.js,prometheus,Node.js,Prometheus,我试图使用Pushgateway将度量值推送到Prometheus中,但无法完成任务。 代码如下: var client = require('prom-client'); var gateway = new client.Pushgateway('http://localhost:9091'); gateway.pushAdd({ jobName: 'test', group : "production" }, function(err, resp, body){ }); 普罗米修斯形态

我试图使用
Pushgateway
将度量值推送到
Prometheus
中,但无法完成任务。 代码如下:

var  client = require('prom-client');
var gateway = new client.Pushgateway('http://localhost:9091');
gateway.pushAdd({ jobName: 'test', group : "production" }, function(err, resp, body){

});
普罗米修斯形态:

scrape_interval:     15s 
evaluation_interval: 15s 

external_labels:
      monitor: 'codelab-monitor'

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

scrape_configs:
  - job_name: 'example-random'
    scrape_interval: 5s

static_configs:
  - targets: ['localhost:8080', 'localhost:8081']
    labels:
      group: 'production'

  - targets: ['localhost:8082']
    labels:
      group: 'canary'

scrape_configs:

  - job_name: 'test '
    static_configs:
      - targets: ['localhost:9091']

您的prometheus配置有一些问题-请查看prometheus github repo和,以备将来参考

一个问题是您有多个
scrape\u配置
。 普罗米修斯的配置中只能有一个
scrape\u配置

另一个问题是,每个作业只能有一个
静态配置

其余的主要原因是格式不正确

下面编辑的配置现在应该适合您了:

global:
  scrape_interval:     15s
  evaluation_interval: 15s

  external_labels:
    monitor: 'codelab-monitor'

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'production'
    static_configs:
      - targets: ['localhost:8080', 'localhost:8081']
        labels:
          group: 'production'

  - job_name: 'canary'
    static_configs:
      - targets: ['localhost:8082']
        labels:
          group: 'canary'

  - job_name: 'test'
    static_configs:
      - targets: ['localhost:9091']

还需要注意的是,Pushgateway中的指标并没有被推送到普罗米修斯手中。普罗米修斯是基于拉动的,将从Pushgateway本身拉动度量。收集的度量值通过临时作业和批处理作业推送到它。

您可以编辑您的问题以包括您的普罗米修斯配置吗?我仍然可以看到在Pushgateway中创建的作业,但无法查询普罗米修斯中的这些度量值。所以可能是普罗米修斯无法把它从大门上拉下来。