dotdc Grafana Dashboards for Kubernetes

repository·master·Indexed 25 days ago

https://github.com/dotdc/grafana-dashboards-kubernetes

A collection of modern Grafana dashboards for Kubernetes monitoring, optimized for the kube-prometheus-stack. Requires kube-state-metrics and prometheus-node-exporter. Includes specialized dashboards for the API Server, CoreDNS, Prometheus, Trivy Operator, and global, namespace, node, and pod views. Supports installation via ArgoCD, Helm, Kubernetes ConfigMaps, Terraform, and the Grafana Operator.

Tokens
3.3K
Snippets
10
Records
18
Agent score
37%

What's inside grafana-dashboards-kubernetes

  1. Overview of grafana-dashboards-kubernetes

    master
    This project provides a modern set of Grafana dashboards specifically designed for Kubernetes monitoring. The dashboards are optimized for use with the kube-prometheus-stack Helm chart, but are compatible with any setup that includes kube-state-metrics and prometheus-node-exporter.
  2. Install dashboards as Kubernetes ConfigMaps

    master

    Dashboards can be provisioned as ConfigMaps using Kustomize. This requires the Grafana dashboards sidecar to be enabled.

    To preview the generated ConfigMaps on STDOUT:

    kubectl kustomize .

    To deploy them directly to a specific namespace (e.g., monitoring):

    kubectl apply -k . -n monitoring

    Note: The default namespace is defined in kustomization.yaml.

    kubectl kustomize .
    # OR
    kubectl apply -k . -n monitoring
  3. Requirements for using these dashboards

    master

    To use these dashboards effectively, your Kubernetes cluster must have the following components installed:

    • kube-state-metrics: For Kubernetes object metrics.
    • prometheus-node-exporter: For node-level metrics.

    While designed for the kube-prometheus-stack, they work with other Prometheus setups as long as the above metrics are available. Note that these dashboards utilize features from newer Grafana versions, including gradient mode (Grafana 8.1+), time series panels (Grafana 7.4+), and the $__rate_interval variable (Grafana 7.2+).

  4. Install dashboards manually in Grafana

    master

    To install dashboards manually:

    1. In the Grafana UI, hover over the + sign in the left menu and click Import.
    2. Option A (Upload): Click the Upload JSON file button and select the JSON files from your local clone of the repository.
    3. Option B (Grafana.com): Enter the specific Dashboard ID from the Grafana.com list into the Import via grafana.com field and click Load.
  5. Install dashboards using Grafana Operator

    master

    If using the Grafana Operator, you can provision dashboards using the GrafanaDashboard custom resource. You must specify the url pointing to the raw JSON file in the repository and ensure the instanceSelector matches your Grafana instance labels.

    apiVersion: grafana.integreatly.org/v1beta1
    kind: GrafanaDashboard
    metadata:
      name: k8s-system-api-server
      namespace: monitoring
    spec:
      instanceSelector:
        matchLabels:
          dashboards: "grafana"
      url: "https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-api-server.json"
  6. Install dashboards as ConfigMaps with Terraform

    master

    To use these dashboards with Terraform, use tfk8s to convert the generated ConfigMaps into Terraform code.

    kubectl kustomize . | tfk8s

    Ensure the Grafana dashboards sidecar is enabled. You must also have the dashboards sidecar configured to watch the namespace where these ConfigMaps are deployed.

  7. Configure the Grafana dashboards sidecar

    master

    When deploying dashboards via ArgoCD, ConfigMaps, Terraform, or Helm, you must enable and configure the dashboards sidecar in your Grafana Helm chart (e.g., kube-prometheus-stack). This allows Grafana to automatically load dashboards from Kubernetes resources.

    Key configuration settings include:

    • enabled: Set to true.
    • defaultFolderName: The default folder for dashboards (e.g., "General").
    • label: The label used to identify dashboards (default: grafana_dashboard).
    • labelValue: The value of the label (default: 1).
    • folderAnnotation: Annotation used for folder organization (default: grafana_folder).
    • searchNamespace: The namespace to search for dashboards (e.g., ALL).
    • provider.foldersFromFilesStructure: Set to true to use file structure for folders.
    # kube-prometheus-stack values
    grafana:
      sidecar:
        dashboards:
          enabled: true
          defaultFolderName: "General"
          label: grafana_dashboard
          labelValue: "1"
          folderAnnotation: grafana_folder
          searchNamespace: ALL
          provider:
            foldersFromFilesStructure: true
  8. Install dashboards using Helm values

    master

    You can install dashboards directly using dashboardProviders and dashboards values in your Helm chart.

    For kube-prometheus-stack: Use the grafana: prefix. For official Grafana helm chart: Remove the grafana: prefix and reduce the indentation level of the entire block.

    grafana:
      # Provision grafana-dashboards-kubernetes
      dashboardProviders:
        dashboardproviders.yaml:
          apiVersion: 1
          providers:
          - name: 'grafana-dashboards-kubernetes'
            orgId: 1
            folder: 'Kubernetes'
            type: file
            disableDeletion: true
            editable: true
            options:
              path: /var/lib/grafana/dashboards/grafana-dashboards-kubernetes
      dashboards:
        grafana-dashboards-kubernetes:
          k8s-system-api-server:
            url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-api-server.json
            token: ''
          k8s-system-coredns:
            url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-system-coredns.json
            token: ''
          k8s-views-global:
            url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-global.json
            token: ''
          k8s-views-namespaces:
            url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-namespaces.json
            token: ''
          k8s-views-nodes:
            url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-nodes.json
            token: ''
          k8s-views-pods:
            url: https://raw.githubusercontent.com/dotdc/grafana-dashboards-kubernetes/master/dashboards/k8s-views-pods.json
            token: ''
  9. Fix broken panels on k8s-views-nodes due to nodename label mismatch

    master

    The k8s-views-nodes dashboard may show broken panels if the node label from kube_node_info does not match the nodename label from node_uname_info. This often occurs when the node exporter is deployed via a DaemonSet.

    You can fix this by relabeling the metric to force the nodename label to match the Kubernetes node name using one of the following methods depending on your deployment type.

  10. Fix broken panels due to high resolution

    master

    If panels appear broken when using Grafana Agent or Grafana Mimir, it may be due to the $resolution variable being set too low. You can resolve this by:

    1. Manually changing the $resolution variable to a higher value (which results in a lower resolution).
    2. Making the fix permanent by configuring the Scrape interval in your Grafana Datasource to a value compatible with your setup.