如何减少普罗米修斯(联邦)刮擦时间

时间:2018-11-20 15:49:46

标签: kubernetes monitoring prometheus

我有一个Prometheus联合会,其中有2个普罗米修斯的服务器-每个Kubernetes集群一个,并由一个中央服务器来统治所有这些服务器。

随着时间的推移,刮擦时间会增加。在某个时刻,抓取时间超过了超时时间,然后指标丢失并发出警报。

我正试图通过降低指标来缩短抓取时间,但这是一场艰苦的战斗,更像是西西弗斯然后是普罗米修斯。

有没有人知道一种减少抓取时间而又不会丢失指标并且不必随着时间的推移而不断下降的方法?

谢谢!

1 个答案:

答案 0 :(得分:1)

根据Prometheus的documentation,这些设置确定全局超时和警报规则的评估频率:

Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.

...并且对于每个抓取作业,configuration允许设置特定于工作的值:

describe('/candidateID route', () => {
  it('gets the candidate info', function (done) {
    chai.request(server)
      .get('/candidateInfo/' + candidateId + '/' + reqNum)
      .set('jwt', vcapServices.JWT_TOKEN)
      .end(function (err, res) {
        if(err) {
          done(err);
          return;
        }
        expect(res).to.have.status(200);
        res.body.should.be.a('array');
        res.body.length.should.be.eql(1);
        expect(res.body[0]).to.have.a.property('applicantId');
        expect(res.body[0]).to.have.a.property('requistionNumber');
        expect(res.body[0]).to.have.a.property('firstName');
        expect(res.body[0]).to.have.a.property('lastName');
        expect(res.body[0]).to.have.a.property('emailAddress');
        expect(res.body[0]).to.have.a.property('storeNumber');
        expect(res.body[0]).to.have.a.property('locationCountry');
        expect(res.body[0]).to.have.a.property('locationStateCode');
        expect(res.body[0]).to.have.a.property('firstAddress');
        expect(res.body[0]).to.have.a.property('secondAddress');
        expect(res.body[0]).to.have.a.property('thirdAddress');
        expect(res.body[0]).to.have.a.property('cityName');
        expect(res.body[0]).to.have.a.property('state');
        expect(res.body[0]).to.have.a.property('zipCode');
        done();
      });
  });
});

不了解更多目标数量和每个目标的指标数量...我建议尝试为每个作业配置适当的global: # How frequently to scrape targets by default. [ scrape_interval: <duration> | default = 1m ] # How long until a scrape request times out. [ scrape_timeout: <duration> | default = 10s ] # How frequently to evaluate rules. [ evaluation_interval: <duration> | default = 1m ] ,并相应地调整全局# The job name assigned to scraped metrics by default. job_name: <job_name> # How frequently to scrape targets from this job. [ scrape_interval: <duration> | default = <global_config.scrape_interval> ] # Per-scrape timeout when scraping this job. [ scrape_timeout: <duration> | default = <global_config.scrape_timeout> ]

结合以上建议或单独使用的建议,另一种选择可以是让普罗米修斯实例专用于抓取不重叠的目标集。因此,有可能按比例缩放普罗米修斯,并使每个目标集具有不同的scrape_timeout。例如,对于花费较长时间的作业,evaluation_interval的使用时间较长,evaluation_interval的使用频率较低,因此不会影响其他作业。

此外,还可以通过一段时间内累积指标来检查出口商的行为是否正常,而不仅仅是在抓取时提供当前读数-否则,返回普罗米修斯的清单会随着时间的推移不断增加。