首页 > 解决方案 > Loki 设置为 Prometheus 数据源以便对日志计数发出警报,配置错误,出现 404 错误

问题描述

kube-prometheus-stack我们在helm 图表中添加了两次 Loki 作为 grafana 的附加数据源,第一个是 type loki,第二个是 type prometheus,第二个是允许 grafana 从 loki 获得警报的唯一 hack:

grafana:
  ## Configure additional grafana datasources (passed through tpl)
  ## ref: http://docs.grafana.org/administration/provisioning/#datasources
  additionalDataSources:
    - name: Loki
      type: loki
      access: proxy
      url: http://loki.monitoring.svc.cluster.local:3100
      jsonData:
        maxLines: 1000
    - name: LokiAsPrometheus
      type: prometheus
      access: proxy
      url: http://loki.monitoring.svc.cluster.local:3100
      jsonData:
        maxLines: 1000

但是当我创建一个新的仪表板并选择LokiAsPromtheus作为数据源时,grafana http 响应会响应错误,就像配置错误一样。

标签: kubernetesprometheusgrafanagrafana-lokikube-prometheus-stack

解决方案


/loki资源作为 loki-as-prometheus url 的一部分至关重要,如下所示:

grafana:
  ## Configure additional grafana datasources (passed through tpl)
  ## ref: http://docs.grafana.org/administration/provisioning/#datasources
  additionalDataSources:
    - name: Loki
      type: loki
      access: proxy
      url: http://loki.monitoring.svc.cluster.local:3100
      jsonData:
        maxLines: 1000
    - name: LokiAsPrometheus
      type: prometheus
      access: proxy
      url: http://loki.monitoring.svc.cluster.local:3100/loki
      jsonData:
        maxLines: 1000

推荐阅读