summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorPromise Akpan <akpanpromise@hotmail.com>2019-08-14 16:04:49 +0100
committerJoel Hans <joel@netdata.cloud>2019-08-14 08:04:49 -0700
commit398fdc44a66d21fee7e1b13a4cd63a21d6fdfd7e (patch)
tree3a0c6ac742cdc2c1a044b2e8544f56941dd0a82e /backends
parent6262597923df989d4b9fc216f1645b006059da19 (diff)
Prometheus version update (#6652)
* fix prometheus version download link * fix prometheus version and few lint warnings * remove specific version of prometheus * remove prometheus versions and some minor fixes
Diffstat (limited to 'backends')
-rw-r--r--backends/WALKTHROUGH.md70
-rw-r--r--backends/prometheus/README.md51
2 files changed, 62 insertions, 59 deletions
diff --git a/backends/WALKTHROUGH.md b/backends/WALKTHROUGH.md
index 7f1dda66f4..50cd08b254 100644
--- a/backends/WALKTHROUGH.md
+++ b/backends/WALKTHROUGH.md
@@ -47,14 +47,14 @@ before we do this we want name resolution between the two containers to work.
In order to accomplish this we will create a user-defined network and attach
both containers to this network. The first command we should run is:
-```
+```sh
docker network create --driver bridge netdata-tutorial
```
With this user-defined network created we can now launch our container we will
install Netdata on and point it to this network.
-```
+```sh
docker run -it --name netdata --hostname netdata --network=netdata-tutorial -p 19999:19999 centos:latest '/bin/bash'
```
@@ -72,19 +72,19 @@ several one-liners to install Netdata. I have not had any issues with these one
liners and their bootstrapping scripts so far (If you guys run into anything do
share). Run the following command in your container.
-```
+```sh
bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-wait
```
After the install completes you should be able to hit the Netdata dashboard at
-http://localhost:19999/ (replace localhost if you’re doing this on a VM or have
+<http://localhost:19999/> (replace localhost if you’re doing this on a VM or have
the docker container hosted on a machine not on your local system). If this is
your first time using Netdata I suggest you take a look around. The amount of
time I’ve spent digging through /proc and calculating my own metrics has been
greatly reduced by this tool. Take it all in.
Next I want to draw your attention to a particular endpoint. Navigate to
-http://localhost:19999/api/v1/allmetrics?format=prometheus&help=yes In your
+<http://localhost:19999/api/v1/allmetrics?format=prometheus&help=yes> In your
browser. This is the endpoint which publishes all the metrics in a format which
Prometheus understands. Let’s take a look at one of these metrics.
`netdata_system_cpu_percentage_average{chart="system.cpu",family="cpu",dimension="system"}
@@ -107,43 +107,43 @@ the install process and setup on a fresh container. This will allow anyone
reading to migrate this tutorial to a VM or Server of any sort.
Let’s start another container in the same fashion as we did the Netdata
-container. `docker run -it --name prometheus --hostname prometheus
---network=netdata-tutorial -p 9090:9090 centos:latest '/bin/bash'` This should
-drop you into a shell once again. Once there quickly install your favorite
-editor as we will be editing files later in this tutorial. `yum install vim -y`
+container.
+
+```sh
+docker run -it --name prometheus --hostname prometheus
+--network=netdata-tutorial -p 9090:9090 centos:latest '/bin/bash'
+```
-Prometheus provides a tarball of their latest stable versions here:
-https://prometheus.io/download/. Let’s download the latest version and install
-into your container.
+This should drop you into a shell once again. Once there quickly install your favorite editor as we will be editing files later in this tutorial.
+```sh
+yum install vim -y
```
-curl -L 'https://github.com/prometheus/prometheus/releases/download/v1.7.1/prometheus-1.7.1.linux-amd64.tar.gz' -o /tmp/prometheus.tar.gz
+
+Prometheus provides a tarball of their latest stable versions [here](https://prometheus.io/download/).
+
+Let’s download the latest version and install into your container.
+
+```sh
+cd /tmp && curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest \
+| grep "browser_download_url.*linux-amd64.tar.gz" \
+| cut -d '"' -f 4 \
+| wget -qi -
mkdir /opt/prometheus
-tar -xf /tmp/prometheus.tar.gz -C /opt/prometheus/ --strip-components 1
+sudo tar -xvf /tmp/prometheus-*linux-amd64.tar.gz -C /opt/prometheus --strip=1
```
-This should get prometheus installed into the container. Let’s test that we can run
-prometheus and connect to it’s web interface. This will look similar to what
-follows:
+This should get prometheus installed into the container. Let’s test that we can run prometheus and connect to it’s web interface.
-```
-[root@prometheus prometheus]# /opt/prometheus/prometheus
-INFO[0000] Starting prometheus (version=1.7.1, branch=master, revision=3afb3fffa3a29c3de865e1172fb740442e9d0133)
- source="main.go:88"
-INFO[0000] Build context (go=go1.8.3, user=root@0aa1b7fc430d, date=20170612-11:44:05) source="main.go:89"
-INFO[0000] Host details (Linux 4.9.36-moby #1 SMP Wed Jul 12 15:29:07 UTC 2017 x86_64 prometheus (none)) source="main.go:90"
-INFO[0000] Loading configuration file prometheus.yml source="main.go:252"
-INFO[0000] Loading series map and head chunks... source="storage.go:428"
-INFO[0000] 0 series loaded. source="storage.go:439"
-INFO[0000] Starting target manager... source="targetmanager.go:63"
-INFO[0000] Listening on :9090 source="web.go:259"
+```sh
+/opt/prometheus/prometheus
```
-Now attempt to go to http://localhost:9090/. You should be presented with the
+Now attempt to go to <http://localhost:9090/>. You should be presented with the
prometheus homepage. This is a good point to talk about Prometheus’s data model
-which can be viewed here: https://prometheus.io/docs/concepts/data_model/ As
+which can be viewed here: <https://prometheus.io/docs/concepts/data_model/> As
explained we have two key elements in Prometheus metrics. We have the ‘metric’
and its ‘labels’. Labels allow for granularity between metrics. Let’s use our
previous example to further explain.
@@ -162,7 +162,7 @@ Let’s move our attention to Prometheus’s configuration. Prometheus gets it
config from the file located (in our example) at
`/opt/prometheus/prometheus.yml`. I won’t spend an extensive amount of time
going over the configuration values documented here:
-https://prometheus.io/docs/operating/configuration/. We will be adding a new
+<https://prometheus.io/docs/operating/configuration/>. We will be adding a new
“job” under the “scrape_configs”. Let’s make the “scrape_configs” section look
like this (we can use the dns name Netdata due to the custom user-defined
network we created in docker beforehand).
@@ -189,7 +189,7 @@ scrape_configs:
```
Let’s start prometheus once again by running `/opt/prometheus/prometheus`. If we
-now navigate to prometheus at ‘http://localhost:9090/targets’ we should see our
+now navigate to prometheus at ‘<http://localhost:9090/targets>’ we should see our
target being successfully scraped. If we now go back to the Prometheus’s
homepage and begin to type ‘netdata_’ Prometheus should auto complete metrics
it is now scraping.
@@ -206,7 +206,7 @@ the following:
Our NetData cpu graph should be showing some activity. Let’s represent this in
Prometheus. In order to do this let’s keep our metrics page open for reference:
-http://localhost:19999/api/v1/allmetrics?format=prometheus&help=yes We are
+<http://localhost:19999/api/v1/allmetrics?format=prometheus&help=yes> We are
setting out to graph the data in the CPU chart so let’s search for “system.cpu”
in the metrics page above. We come across a section of metrics with the first
comments `# COMMENT homogeneous chart "system.cpu", context "system.cpu", family
@@ -249,7 +249,7 @@ can send metrics “as-collected” by specifying the ‘source=as-collected’
parameter like so.
http://localhost:19999/api/v1/allmetrics?format=prometheus&help=yes&types=yes&source=as-collected
If you choose to use this method you will need to use Prometheus's set of
-functions here: https://prometheus.io/docs/querying/functions/ to obtain useful
+functions here: <https://prometheus.io/docs/querying/functions/> to obtain useful
metrics as you are now dealing with raw counters from the system. For example
you will have to use the `irate()` function over a counter to get that metric's
rate per second. If your graphing needs are met by using the metrics returned by
@@ -266,7 +266,7 @@ we need to do is done via the GUI. Let’s run the following command:
docker run -i -p 3000:3000 --network=netdata-tutorial grafana/grafana
```
-This will get grafana running at ‘http://localhost:3000/’ Let’s go there and
+This will get grafana running at ‘<http://localhost:3000/>’ Let’s go there and
login using the credentials Admin:Admin.
The first thing we want to do is click ‘Add data source’. Let’s make it look
diff --git a/backends/prometheus/README.md b/backends/prometheus/README.md
index f879ba35a3..ddd729bf68 100644
--- a/backends/prometheus/README.md
+++ b/backends/prometheus/README.md
@@ -4,7 +4,6 @@
Prometheus is a distributed monitoring system which offers a very simple setup along with a robust data model. Recently Netdata added support for Prometheus. I'm going to quickly show you how to install both Netdata and prometheus on the same server. We can then use grafana pointed at Prometheus to obtain long term metrics Netdata offers. I'm assuming we are starting at a fresh ubuntu shell (whether you'd like to follow along in a VM or a cloud instance is up to you).
-
## Installing Netdata and prometheus
### Installing Netdata
@@ -12,7 +11,7 @@ Prometheus is a distributed monitoring system which offers a very simple setup a
There are number of ways to install Netdata according to [Installation](../../packaging/installer/#installation)
The suggested way of installing the latest Netdata and keep it upgrade automatically. Using one line installation:
-```
+```sh
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
```
@@ -22,7 +21,7 @@ At this point we should have Netdata listening on port 19999. Attempt to take yo
http://your.netdata.ip:19999
```
-*(replace `your.netdata.ip` with the IP or hostname of the server running Netdata)*
+_(replace `your.netdata.ip` with the IP or hostname of the server running Netdata)_
### Installing Prometheus
@@ -31,7 +30,10 @@ In order to install prometheus we are going to introduce our own systemd startup
#### Download Prometheus
```sh
-wget -O /tmp/prometheus-2.3.2.linux-amd64.tar.gz https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz
+cd /tmp && curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest \
+| grep "browser_download_url.*linux-amd64.tar.gz" \
+| cut -d '"' -f 4 \
+| wget -qi -
```
#### Create prometheus system user
@@ -50,7 +52,7 @@ sudo chown prometheus:prometheus /opt/prometheus
#### Untar prometheus directory
```sh
-sudo tar -xvf /tmp/prometheus-2.3.2.linux-amd64.tar.gz -C /opt/prometheus --strip=1
+sudo tar -xvf /tmp/prometheus-*linux-amd64.tar.gz -C /opt/prometheus --strip=1
```
#### Install prometheus.yml
@@ -111,8 +113,8 @@ scrape_configs:
#### Install nodes.yml
-The following is completely optional, it will enable Prometheus to generate alerts from some NetData sources. Tweak the values to your own needs. We will use the following `nodes.yml` file below. Save it at `/opt/prometheus/nodes.yml`, and add a *- "nodes.yml"* entry under the *rule_files:* section in the example prometheus.yml file above.
-```
+The following is completely optional, it will enable Prometheus to generate alerts from some NetData sources. Tweak the values to your own needs. We will use the following `nodes.yml` file below. Save it at `/opt/prometheus/nodes.yml`, and add a _- "nodes.yml"_ entry under the _rule_files:_ section in the example prometheus.yml file above.
+```yaml
groups:
- name: nodes
@@ -173,7 +175,7 @@ WantedBy=multi-user.target
```
##### Start Prometheus
-```
+```sh
sudo systemctl start prometheus
sudo systemctl enable prometheus
```
@@ -192,21 +194,21 @@ Before explaining the changes, we have to understand the key differences between
### understanding Netdata metrics
-##### charts
+#### charts
Each chart in Netdata has several properties (common to all its metrics):
-- `chart_id` - uniquely identifies a chart.
+- `chart_id` - uniquely identifies a chart.
-- `chart_name` - a more human friendly name for `chart_id`, also unique.
+- `chart_name` - a more human friendly name for `chart_id`, also unique.
-- `context` - this is the template of the chart. All disk I/O charts have the same context, all mysql requests charts have the same context, etc. This is used for alarm templates to match all the charts they should be attached to.
+- `context` - this is the template of the chart. All disk I/O charts have the same context, all mysql requests charts have the same context, etc. This is used for alarm templates to match all the charts they should be attached to.
-- `family` groups a set of charts together. It is used as the submenu of the dashboard.
+- `family` groups a set of charts together. It is used as the submenu of the dashboard.
-- `units` is the units for all the metrics attached to the chart.
+- `units` is the units for all the metrics attached to the chart.
-##### dimensions
+#### dimensions
Then each Netdata chart contains metrics called `dimensions`. All the dimensions of a chart have the same units of measurement, and are contextually in the same category (ie. the metrics for disk bandwidth are `read` and `write` and they are both in the same chart).
@@ -214,7 +216,7 @@ Then each Netdata chart contains metrics called `dimensions`. All the dimensions
Netdata can send metrics to prometheus from 3 data sources:
-- `as collected` or `raw` - this data source sends the metrics to prometheus as they are collected. No conversion is done by Netdata. The latest value for each metric is just given to prometheus. This is the most preferred method by prometheus, but it is also the harder to work with. To work with this data source, you will need to understand how to get meaningful values out of them.
+- `as collected` or `raw` - this data source sends the metrics to prometheus as they are collected. No conversion is done by Netdata. The latest value for each metric is just given to prometheus. This is the most preferred method by prometheus, but it is also the harder to work with. To work with this data source, you will need to understand how to get meaningful values out of them.
The format of the metrics is: `CONTEXT{chart="CHART",family="FAMILY",dimension="DIMENSION"}`.
@@ -222,13 +224,13 @@ Netdata can send metrics to prometheus from 3 data sources:
Unlike prometheus, Netdata allows each dimension of a chart to have a different algorithm and conversion constants (`multiplier` and `divisor`). In this case, that the dimensions of a charts are heterogeneous, Netdata will use this format: `CONTEXT_DIMENSION{chart="CHART",family="FAMILY"}`
-- `average` - this data source uses the Netdata database to send the metrics to prometheus as they are presented on the Netdata dashboard. So, all the metrics are sent as gauges, at the units they are presented in the Netdata dashboard charts. This is the easiest to work with.
+- `average` - this data source uses the Netdata database to send the metrics to prometheus as they are presented on the Netdata dashboard. So, all the metrics are sent as gauges, at the units they are presented in the Netdata dashboard charts. This is the easiest to work with.
The format of the metrics is: `CONTEXT_UNITS_average{chart="CHART",family="FAMILY",dimension="DIMENSION"}`.
When this source is used, Netdata keeps track of the last access time for each prometheus server fetching the metrics. This last access time is used at the subsequent queries of the same prometheus server to identify the time-frame the `average` will be calculated. So, no matter how frequently prometheus scrapes Netdata, it will get all the database data. To identify each prometheus server, Netdata uses by default the IP of the client fetching the metrics. If there are multiple prometheus servers fetching data from the same Netdata, using the same IP, each prometheus server can append `server=NAME` to the URL. Netdata will use this `NAME` to uniquely identify the prometheus server.
-- `sum` or `volume`, is like `average` but instead of averaging the values, it sums them.
+- `sum` or `volume`, is like `average` but instead of averaging the values, it sums them.
The format of the metrics is: `CONTEXT_UNITS_sum{chart="CHART",family="FAMILY",dimension="DIMENSION"}`.
All the other operations are the same with `average`.
@@ -241,7 +243,7 @@ Fetch with your web browser this URL:
`http://your.netdata.ip:19999/api/v1/allmetrics?format=prometheus&help=yes`
-*(replace `your.netdata.ip` with the ip or hostname of your Netdata server)*
+_(replace `your.netdata.ip` with the ip or hostname of your Netdata server)_
Netdata will respond with all the metrics it sends to prometheus.
@@ -272,7 +274,8 @@ netdata_system_cpu_percentage_average{chart="system.cpu",family="cpu",dimension=
# COMMENT netdata_system_cpu_percentage_average: dimension "idle", value is percentage, gauge, dt 1500066653 to 1500066662 inclusive
netdata_system_cpu_percentage_average{chart="system.cpu",family="cpu",dimension="idle"} 92.3630770 1500066662000
```
-*(Netdata response for `system.cpu` with source=`average`)*
+
+_(Netdata response for `system.cpu` with source=`average`)_
In `average` or `sum` data sources, all values are normalized and are reported to prometheus as gauges. Now, use the 'expression' text form in prometheus. Begin to type the metrics we are looking for: `netdata_system_cpu`. You should see that the text form begins to auto-fill as prometheus knows about this metric.
@@ -302,7 +305,7 @@ netdata_system_cpu_total{chart="system.cpu",family="cpu",dimension="iowait"} 233
netdata_system_cpu_total{chart="system.cpu",family="cpu",dimension="idle"} 918470 1500066716438
```
-*(Netdata response for `system.cpu` with source=`as-collected`)*
+_(Netdata response for `system.cpu` with source=`as-collected`)_
For more information check prometheus documentation.
@@ -310,7 +313,7 @@ For more information check prometheus documentation.
The `format=prometheus` parameter only exports the host's Netdata metrics. If you are using the master/slave functionality of Netdata this ignores any upstream hosts - so you should consider using the below in your **prometheus.yml**:
-```
+```yaml
metrics_path: '/api/v1/allmetrics'
params:
format: [prometheus_all_hosts]
@@ -348,8 +351,8 @@ The default is controlled in `netdata.conf`:
You can overwrite it from prometheus, by appending to the URL:
-* `&names=no` to get IDs (the old behaviour)
-* `&names=yes` to get names
+- `&names=no` to get IDs (the old behaviour)
+- `&names=yes` to get names
### Filtering metrics sent to prometheus