Configure Prometheus to monitor the sample targets
Now we will configure Prometheus to scrape these new targets. Let's group all
three endpoints into one job callednode. We will imagine that the
first two endpoints are production targets, while the third one represents a
canary instance. To model this in Prometheus, we can add several groups of
endpoints to a single job, adding extra labels to each group of targets. In
this example, we will add thegroup="production"label to the first group of
targets, while addinggroup="canary"to the second.
To achieve this, add the following job definition to thescrape_configssection in yourprometheus.ymland restart your Prometheus instance:
scrape_configs:-job_name:'node'# Override the global default and scrape targets from this job every 5 seconds.scrape_interval:5sstatic_configs:-targets: ['localhost:8080','localhost:8081']labels:group:'production'-targets: ['localhost:8082']labels:group:'canary'
Go to the expression browser and verify that Prometheus now has information
about time series that these example endpoints expose, such asnode_cpu_seconds_total.