Grafana Cloud

Send Kubernetes metrics, logs, and events to Grafana Cloud with Helm and Ansible

You can use Helm and Ansible to configure Kubernetes Monitoring, and use:

  • The Kubernetes Monitoring GUI
  • Preconfigured alerts and recording rules

Before you begin

Make sure you have the following available:

  • Ansible CLI installed in your system
  • Access to a Kubernetes Cluster
  • The Admin role to install preconfigured components

Configuration steps

The steps to configure Kubernetes Monitoring with Ansible are:

  1. Use a Grafana Cloud Access Policy token.
  2. Install the preconfigured components.
  3. Set up the Ansible Playbook
  4. Run the Ansible Playbook.

Create or gather Grafana Cloud Access Policy token

You can create a new access policy token or look up an existing token. See Grafana Cloud Access Policies for more information.

You’ll use this token in a future step.

Install preconfigured alerts and recording rules

To install preconfigured alerts and recording rules, complete the following steps:

  1. Navigate to your Grafana Cloud account.
  2. Click the upper-left menu icon to open the main menu.
  3. Click Observability.
  4. Click the Kubernetes tile. The Configuration page appears.
  5. Under the Backend installation section, click Install to install the alerts and recording rules.

Configure the Ansible Playbook


Before you being configuration, find the latest version number of the Helm chart, then enter that version as part of your code.

To install the Kubernetes Monitoring components, complete the following steps.

  1. Copy and paste the following configuration into a terminal:
cat >> grafana-k8s-monitoring.yaml <<'EOF'
- name: Grafana Kubernetes Monitoring
  hosts: localhost

  # Declare variables
    namespace: <NAMESPACE>
    cluster_name: <CLUSTER_NAME>
    metrics_username: <METRICS_USERNAME>
    prometheus_url: <PROMETHEUS_URL>
    logs_username: <LOGS_USERNAME>
    loki_url: <LOKI_URL>
    traces_username: <TRACES_USERNAME>
    tempo_url: <TRACES_URL>
    grafana_cloud_token: <GRAFANA_CLOUD_ACCESS_TOKEN>


    - name: Deploy Grafana Kubernetes Monitoring Helm Chart
        name: grafana-k8s-monitoring
        chart_ref: grafana/k8s-monitoring
        release_namespace: "{{ namespace }}"
        chart_version: 0.2.5
            name: "{{ cluster_name }}"
              host: "{{ prometheus_url }}"
                username: "{{ metrics_username }}"
                password: "{{ grafana_cloud_token }}"
              host: "{{ loki_url }}"
                username: "{{ logs_username }}"
                password: "{{ grafana_cloud_token }}"
              host: "{{ tempo_url }}"
                username: "{{ traces_username }}"
                password: "{{ grafana_cloud_token }}"
                defaultClusterId: "{{ cluster_name }}"
                  url: "{{ prometheus_url }}/api/prom"
            enabled: true
                - name: otlp-traces
                  port: 4317
                  targetPort: 4317
                  protocol: TCP
  1. Replace the following in the code:

    • NAMESPACE with your namespace where you want to deploy Kubernetes Monitoring resources
    • CLUSTER_NAME with your Cluster name
    • METRICS_USERNAME with the Prometheus instance ID
    • PROMETHEUS_URL with the push endpoint URL of the Prometheus instance
    • LOGS_USERNAME with Loki Username
    • LOKI_URL with the push endpoint URL of the Loki instance
    • TRACES_USERNAME with Tempo Username
    • TEMPO_URL with the push endpoint URL of the Tempo instance
    • GRAFANA_CLOUD_ACCESS_TOKEN with your Grafana Cloud Access token

Run the Ansible Playbook

Complete the following steps to run the Ansible Playbook and deploy the resources.

  1. Open a terminal or shell.

  2. Navigate to the directory where the Ansible Playbook is located.

  3. Run the following command to run the Ansible Playbook:

    ansible-playbook grafana-k8s-monitoring.yaml

    This command will run the Ansible Playbook, Installing the Kubernetes Monitoring components in your cluster.

Next steps

  1. Navigate to Kubernetes Monitoring, and click Configuration on the main menu.

  2. Click the Metrics status tab to view the data status. Your data begins populating in the view as the system components begin scraping and sending data to Grafana Cloud.

    Descriptions and statuses for each item chosen to be configured and whether they are online
    Metrics status tab