Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Set up a Prometheus host on an Amazon EC2 instance

Focus mode
Set up a Prometheus host on an Amazon EC2 instance - Amazon Managed Streaming for Apache Kafka

This procedure descrbies how to set up a Prometheus host using a prometheus.yml file.

  1. Download the Prometheus server from https://prometheus.io/download/#prometheus to your Amazon EC2 instance.

  2. Extract the downloaded file to a directory and go to that directory.

  3. Create a file with the following contents and name it prometheus.yml.

    # file: prometheus.yml # my global config global: scrape_interval: 60s # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' static_configs: # 9090 is the prometheus server port - targets: ['localhost:9090'] - job_name: 'broker' file_sd_configs: - files: - 'targets.json'
  4. Use the ListNodes operation to get a list of your cluster's brokers.

  5. Create a file named targets.json with the following JSON. Replace broker_dns_1, broker_dns_2, and the rest of the broker DNS names with the DNS names you obtained for your brokers in the previous step. Include all of the brokers you obtained in the previous step. Amazon MSK uses port 11001 for the JMX Exporter and port 11002 for the Node Exporter.

    ZooKeeper mode targets.json
    [ { "labels": { "job": "jmx" }, "targets": [ "broker_dns_1:11001", "broker_dns_2:11001", . . . "broker_dns_N:11001" ] }, { "labels": { "job": "node" }, "targets": [ "broker_dns_1:11002", "broker_dns_2:11002", . . . "broker_dns_N:11002" ] } ]
    KRaft mode targets.json
    [ { "labels": { "job": "jmx" }, "targets": [ "broker_dns_1:11001", "broker_dns_2:11001", . . . "broker_dns_N:11001", "controller_dns_1:11001", "controller_dns_2:11001", "controller_dns_3:11001" ] }, { "labels": { "job": "node" }, "targets": [ "broker_dns_1:11002", "broker_dns_2:11002", . . . "broker_dns_N:11002" ] } ]
    [ { "labels": { "job": "jmx" }, "targets": [ "broker_dns_1:11001", "broker_dns_2:11001", . . . "broker_dns_N:11001" ] }, { "labels": { "job": "node" }, "targets": [ "broker_dns_1:11002", "broker_dns_2:11002", . . . "broker_dns_N:11002" ] } ]
    Note

    To scrape JMX metrics from KRaft controllers, add controller DNS names as targets in the JSON file. For example: controller_dns_1:11001, replacing controller_dns_1 with the actual controller DNS name.

  6. To start the Prometheus server on your Amazon EC2 instance, run the following command in the directory where you extracted the Prometheus files and saved prometheus.yml and targets.json.

    ./prometheus
  7. Find the IPv4 public IP address of the Amazon EC2 instance where you ran Prometheus in the previous step. You need this public IP address in the following step.

  8. To access the Prometheus web UI, open a browser that can access your Amazon EC2 instance, and go to Prometheus-Instance-Public-IP:9090, where Prometheus-Instance-Public-IP is the public IP address you got in the previous step.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.