代码之家  ›  专栏  ›  技术社区  ›  online

Grafana HTTP错误网关错误和模板初始化失败错误

  •  13
  • online  · 技术社区  · 7 年前

    使用 helm 安装 Prometheus Grafana 在…上 minikube 在本地。

    $ helm install stable/prometheus
    $ helm install stable/grafana
    

    Prometheus服务器,alertmanager grafana可以在设置端口转发后运行:

    $ export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
    $ kubectl --namespace default port-forward $POD_NAME 9090
    
    $ export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,component=alertmanager" -o jsonpath="{.items[0].metadata.name}")
    $ kubectl --namespace default port-forward $POD_NAME 9093
    
    $ export POD_NAME=$(kubectl get pods --namespace default -l "app=excited-crocodile-grafana,component=grafana" -o jsonpath="{.items[0].metadata.name}")
    $ kubectl --namespace default port-forward $POD_NAME 3000
    

    enter image description here enter image description here

    从grafana添加数据源,获得 HTTP Error Bad Gateway 错误:

    enter image description here

    从以下位置导入仪表板315:

    https://grafana.com/dashboards/315

    然后检查 Kubernetes cluster monitoring (via Prometheus) ,获得 Templating init failed 错误:

    enter image description here

    为什么?

    3 回复  |  直到 7 年前
        1
  •  22
  •   svenwltr    7 年前

    在您设置的Grafana的HTTP设置中 Access Proxy ,这意味着格拉法纳想接近普罗米修斯。由于Kubernetes使用覆盖网络,因此它是一个不同的IP。

    有两种方法可以解决此问题:

    1. 设置 通道 Direct ,因此浏览器直接连接到普罗米修斯。
    2. 使用Kubernetes内部IP或域名。我不知道普罗米修斯掌舵图,但假设有 Service 已命名 prometheus ,类似于 http://prometheus:9090 应该有用。
        2
  •  0
  •   Venkataramana Chigateri    3 年前

    我关闭了设备上的防火墙,发布了添加http://prometheus:9090URL上未引发错误网关错误。

        3
  •  0
  •   Venryx    3 年前

    我一直无法找到“合适的”修复,但我找到了一个解决方法:

    apiVersion: v1
    kind: Service
    metadata:
      labels:
        prometheus: k8s
      name: prometheus-k8s
      namespace: monitoring
    spec:
      selector:
        app: prometheus
        prometheus: k8s
      sessionAffinity: ClientIP
      clusterIP: None
    

    通过设置 clusterIP None ,服务更改为“Headless”模式,这意味着请求将直接发送到该服务/集群中的任意一个pod。更多信息请点击此处: https://kubernetes.io/docs/concepts/services-networking/service/#headless-services

    可能有更好的解决方案,但这是我发现的唯一一个真正适合我的解决方案 kube-prometheus . (我试过docker desktop、k3d和kind,它们都有相同的问题,所以我怀疑这是模拟器的错;我将配置简化为kube prometheus,所以很难理解问题所在,但很好。)