grafana agent metrics 使用简单使用

grafana agent 的能力还是比较强大的,支持log,metrics,trace,以下简单说明下

简单模式

只包含了metrics,不包含集成模式
核心点是metrics 配置,包含了remote write 以及静态或者动态配置(比喻基于文件的服务发现以及基于k8s 的服务发现)

 
server:
  log_level: info
 
metrics:
  global:
    scrape_interval: 1m
  configs:
    - name: agent
      scrape_configs:
        - job_name: agent
          static_configs:
            - targets: ['127.0.0.1:12345']
      remote_write:
        - url: http://localhost:9009/api/prom/push

包含集成的模式

因为agent 嵌入了不少开源exporter,我们可以直接拿来使用,此中模式是一个比较强大而且灵活的能力,我们就了不用安装那个多的exporter 了

server:
  log_level: info
 
metrics:
  global:
    scrape_interval: 1m
    remote_write:
      - url: http://localhost:9009/api/prom/push
  configs:
    - name: default
      scrape_configs:
        - job_name: agent
          static_configs:
            - targets: ['127.0.0.1:12345']
 
integrations:
  node_exporter: {}

说明

目前grafana agent 支持一种基于remote 配置的模式,可以通过使用远端http(s) 的配置,这样就比较方便了,可以简化我们不少配置管理的问题,目前处于体验状态
可以开启使用,此中模式就很不错了,我们可以基于http server 管理配置,可以做到灵活的配置管理,特别适合大量服务管理的时候,期待ga
同时官方目前也在测试一种动态配置模式(基于了gomplate)可以支持不少数据源模式的配置管理,比remote 更加强灵活,也期待ga

参考资料

https://grafana.com/docs/agent/latest/configuration/metrics-config/
https://grafana.com/docs/agent/latest/configuration/logs-config/
https://grafana.com/docs/agent/latest/configuration/traces-config/
https://grafana.com/docs/agent/latest/configuration/dynamic-config/
https://grafana.com/docs/agent/latest/configuration/integrations/
https://grafana.com/docs/agent/latest/configuration/create-config-file/
https://grafana.com/docs/agent/latest/configuration/
https://docs.gomplate.ca/datasources/

posted on 2022-11-06 21:53  荣锋亮  阅读(903)  评论(0编辑  收藏  举报

导航