Integrate with an external Prometheus and Grafana instance

Astra Streaming exposes some of the Pulsar metrics through Prometheus endpoints. The Prometheus configuration information to scrape Astra Streaming metrics into an external Prometheus server is found in the Astra Portal.

This page explains how to set up a Prometheus server in a Kubernetes cluster and configure it to scrape Astra Streaming metrics.

Prerequisites

  • An Astra DB account

  • A Kubernetes cluster

Configure and deploy Prometheus

This example uses the Prometheus Community Kubernetes Helm Charts to set up a Prometheus server and a Grafana server in a Kubernetes cluster.

  1. Download the Astra Streaming Prometheus configuration from the Astra Portal. For more information, see Scrape metrics from Astra Streaming.

  2. Use the downloaded file to create a config.yml.

    This example uses a job named astra-pulsar-metrics-demo. The values in your config.yml depend on your tenant configuration.

    config.yml
      - job_name: "astra-pulsar-metrics-demo"
    
        scheme: 'https'
        metrics_path: '/pulsarmetrics/TENANT_NAME'
        authorization:
          credentials: 'PULSAR_JWT_TOKEN'
    
        static_configs:
          - targets: [https://prometheus-PROVIDER-REGION.streaming.datastax.com/pulsarmetrics/TENANT_NAME]

    Do not add other Prometheus configurations, like scrape_interval or evaluation_interval yet. These are added later when configuring the Helm chart.

  3. Create a Kubernetes secret with the above configuration file, and then apply it:

    kubectl create secret generic SECRET_NAME \
      --from-file=config.yml \
      --dry-run=client -oyaml > k8s-additional-scrape-config-demo.yaml
    kubectl apply -f k8s-additional-scrape-config-demo.yaml

    You can change the name of the YAML output file, if desired.

  4. Create a customized values file (custom-values.yml) for the Prometheus Community Kubernetes Helm chart. In the 'additionalScrapeConfigsSecret' section, make sure the name and key match the name if your Kubernetes secret and config file name, such as astra-secret and config.yml.

    custom-values.yml
    prometheus:
       prometheusSpec:
          scrapeInterval: 60s
          evaluationInterval: 15s
          additionalScrapeConfigsSecret:
             enabled: true
             name: SECRET_NAME
             key: CONFIG_YAML
  5. Deploy the Helm chart:

    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    helm upgrade --install kubeprom -f custom-values.yaml prometheus-community/kube-prometheus-stack
  6. For macOS users who run Docker Desktop as the underlying Kubernetes cluster, run the following commands to ensure the deployment is successful. If you don’t run this command, you might encounter a problem when initializing the Prometheus node exporter daemon set.

    # Patch Prometheus node exporter daemon set
    kubectl patch ds kubeprom-prometheus-node-exporter --type "json" -p '[{"op": "remove", "path" : "/spec/template/spec/containers/0/volumeMounts/2/mountPropagation"}]'
    
    # Confirm Prometheus node exporter daemonset is running properly
    kubectl rollout status daemonset \
      kubeprom-prometheus-node-exporter \
      --timeout 60s
  7. To confirm that Astra Streaming metrics are integrated with your external Prometheus server, go to your external Prometheus server UI. Make sure the additional scrape job is in UP status. If not, review the configuration instructions and YAML examples to ensure your configuration is correct.

    If the additional scrape job returns a 401 Unauthorized error, make sure your Pulsar JWT isn’t expired. For more information, see Manage tokens.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com