Skip to content

Grafana

Grafana is an open-source analytics and interactive visualization web application that provides charts, graphs, and alerts for connected data sources.^[prometheus.md] It is frequently deployed alongside monitoring systems like Prometheus to visualize Metrics.^[prometheus.md]

Deployment

In containerized environments, Grafana is often deployed using Helm charts.^[prometheus.md]

Installation via Helm

The Grafana community maintains a Helm chart available at https://grafana.github.io/helm-charts/.^[prometheus.md] To install Grafana, the following commands can be used to add the repository and deploy the application to a cluster (typically the default namespace):^[prometheus.md]

[Helm](<./helm.md>) repo add grafana https://grafana.github.io/helm-charts
[Helm](<./helm.md>) repo update
[Helm](<./helm.md>) install grafana grafana/grafana

Access and Credentials

Upon installation, the Grafana server can be accessed via port-forwarding the service to the local machine:^[prometheus.md]

export POD_NAME=$([kubectl](<./kubectl.md>) get pods --namespace default -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=grafana" -o jsonpath="{.items[0].metadata.name}")
[kubectl](<./kubectl.md>) --namespace default port-forward $POD_NAME 3000

The default login credentials use admin for the username, with the password retrieved from the Kubernetes Secret:^[prometheus.md]

[kubectl](<./kubectl.md>) get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

Data Source Configuration

Grafana operates by connecting to external databases or monitoring tools. A common configuration involves adding Prometheus as a data source.^[prometheus.md]

When running both tools on the same cluster, Grafana can locate the Prometheus server using the internal Kubernetes DNS or the Cluster IP. For example, if Prometheus is installed in the default namespace, the target URL might be:^[prometheus.md]

  • http://prometheus-server.default.svc.cluster.local
  • http://prometheus-server:80

Dashboards

Users can create custom dashboards or import pre-built configurations. Grafana hosts a library of shared dashboards that can be filtered by topic, such as "Kubernetes", allowing for rapid visualization setup.^[prometheus.md] These dashboards are identified by unique IDs which can be imported directly into the local Grafana instance.^[prometheus.md]

Sources

  • prometheus.md