在 Grafana 中配置的 Prometheus 数据源中设置抓取间隔

Ale*_*uss 2 grafana prometheus

我正在向 grafana 配置 Prometheus 数据源。通过 UI 添加数据源时,我可以设置一个“抓取间隔”,这似乎决定了从 prometheus 获取数据的粒度。

但是,当从 yaml 文件配置数据源时,我无法找到如何在 yaml 文件中设置该值。我尝试了“scrapeInterval”,但它似乎不起作用。

文档只是一个小例子,但没有任何价值。

小智 12

我遇到了同样的问题,也尝试过scrapeInterval,但没有成功。

查看源代码后,我发现可以使用列表项jsonData.timeInterval的字段来设置它datasources。这是一个示例datasource.yaml文件,该字段设置为10s

apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    httpMethod: POST
    url: http://localhost:9090
    jsonData:
      timeInterval: 10s
Run Code Online (Sandbox Code Playgroud)

我在types.ts文件中找到了这个,以及 Prometheus 数据源的其余配置选项。