Commit f0e4a70d authored by James Turnbull's avatar James Turnbull Committed by Brian Brazil

Replace http_requests_total metric (#1078)

Signed-off-by: 's avatarJames Turnbull <james@lovedthanlost.net>
parent 41235fd6
......@@ -5,7 +5,7 @@ sort_rank: 3
# First steps with Prometheus
Welcome to Prometheus! Prometheus is a monitoring platform that collects metrics from monitored targets by scraping metrics HTTP endpoints on these targets. This guide will show you to how to install, configure and monitor our first resource with Prometheus. You'll download, install and run Prometheus. You'll also download and install an exporter, tools that expose time series data on hosts and services. Our first exporter will be the Node Exporter, which exposes host-level metrics like CPU, memory, and disk.
Welcome to Prometheus! Prometheus is a monitoring platform that collects metrics from monitored targets by scraping metrics HTTP endpoints on these targets. This guide will show you to how to install, configure and monitor our first resource with Prometheus. You'll download, install and run Prometheus. You'll also download and install an exporter, tools that expose time series data on hosts and services. Our first exporter will be the Node Exporter, which exposes host-level metrics like CPU, memory, and disk.
## Downloading Prometheus
......@@ -28,7 +28,7 @@ The Prometheus monitoring server
. . .
```
Before starting Prometheus, let's configure it.
Before starting Prometheus, let's configure it.
## Configuring Prometheus
......@@ -51,7 +51,7 @@ scrape_configs:
- targets: ['localhost:9090']
```
There are three blocks of configuration in the example configuration file: `global`, `rule_files`, and `scrape_configs`.
There are three blocks of configuration in the example configuration file: `global`, `rule_files`, and `scrape_configs`.
The `global` block controls the Prometheus server's global configuration. We have two options present. The first, `scrape_interval`, controls how often Prometheus will scrape targets. You can override this for individual targets. In this case the global setting is to scrape every 15 seconds. The `evaluation_interval` option controls how often Prometheus will evaluate rules. Prometheus uses rules to create new time series and to generate alerts.
......@@ -86,24 +86,24 @@ tab.
As you can gather from http://localhost:9090/metrics, one metric that
Prometheus exports about itself is called
`http_requests_total` (the total number of HTTP requests the Prometheus server has made). Go ahead and enter this into the expression console:
`promhttp_metric_handler_requests_total` (the total number of `/metrics` requests the Prometheus server has served). Go ahead and enter this into the expression console:
```
http_requests_total
promhttp_metric_handler_requests_total
```
This should return a number of different time series (along with the latest value recorded for each), all with the metric name `http_requests_total`, but with different labels. These labels designate different types of requests.
This should return a number of different time series (along with the latest value recorded for each), all with the metric name `promhttp_metric_handler_requests_total`, but with different labels. These labels designate different requests statuses.
If we were only interested in requests that resulted in HTTP code `200`, we could use this query to retrieve that information:
```
http_requests_total{code="200"}
promhttp_metric_handler_requests_total{code="200"}
```
To count the number of returned time series, you could write:
```
count(http_requests_total)
count(promhttp_metric_handler_requests_total)
```
For more about the expression language, see the
......@@ -113,10 +113,10 @@ For more about the expression language, see the
To graph expressions, navigate to http://localhost:9090/graph and use the "Graph" tab.
For example, enter the following expression to graph the per-second HTTP request rate happening in the self-scraped Prometheus:
For example, enter the following expression to graph the per-second HTTP request rate returning status code 200 happening in the self-scraped Prometheus:
```
rate(http_requests_total[1m])
rate(promhttp_metric_handler_requests_total{code="200"}[1m])
```
You can experiment with the graph range parameters and other settings.
......@@ -156,16 +156,16 @@ We will configure Prometheus to scrape this new target. To achieve this, add a n
- targets: ['localhost:9100']
```
Our new job is called `node`. It scrapes a static target, `localhost` on port `9100`. You would replace this name with the name or IP address of the host you're monitoring.
Our new job is called `node`. It scrapes a static target, `localhost` on port `9100`. You would replace this name with the name or IP address of the host you're monitoring.
Now we restart our Prometheus server to activate our new job.
Go to the expression browser and verify that Prometheus now has information
about the time series that this endpoint exposes. Navigate to
http://localhost:9090/graph and use the dropdown next to the "Execute" button to see a list of metrics this server is collecting. In the list you'll see a number of metrics prefixed with `node_`, that have been collected by the Node Exporter by our `node` job. For example, you can see the node's CPU usage via the `node_cpu_seconds_total` or `node_exporter_build_info` metric.
http://localhost:9090/graph and use the dropdown next to the "Execute" button to see a list of metrics this server is collecting. In the list you'll see a number of metrics prefixed with `node_`, that have been collected by the Node Exporter by our `node` job. For example, you can see the node's CPU usage via the `node_cpu_seconds_total` or `node_exporter_build_info` metric.
One useful metric to look for is the `up` metric. The `up` metric can be used to track the status of the target. If the metric has a value of `1` then the scrape of the target was successful, if `0` it failed. This can help give you an indication of the status of the target. You'll see two `up` metrics, one for each target we're scraping: the Prometheus server and the Node Exporter.
## Summary
Now you've been introduced to Prometheus, installed it, and configured it to monitor your first resources. We've also installed our first exporter and seen the basics of how to work with time series data scraped using the expression browser. You can find more [documentation](/docs/introduction/overview/) to help you continue to learn more about Prometheus.
Now you've been introduced to Prometheus, installed it, and configured it to monitor your first resources. We've also installed our first exporter and seen the basics of how to work with time series data scraped using the expression browser. You can find more [documentation](/docs/introduction/overview/) to help you continue to learn more about Prometheus.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment