2018-11-27 23:57:24 +00:00
---
title: Monitoring with Prometheus
2019-06-28 17:51:30 +00:00
summary: A Simple recipe to monitor Ozone using Prometheus
linktitle: Prometheus
2018-11-27 23:57:24 +00:00
---
<!-- -
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
2019-04-29 20:28:19 +00:00
[Prometheus ](https://prometheus.io/ ) is an open-source monitoring server developed under under the [Cloud Native Computing Foundation ](https://www.cncf.io/ ).
2018-11-27 23:57:24 +00:00
2019-06-28 17:51:30 +00:00
Ozone supports Prometheus out of the box. The servers start a prometheus
2018-11-27 23:57:24 +00:00
compatible metrics endpoint where all the available hadoop metrics are published in prometheus exporter format.
## Prerequisites
2019-06-28 17:51:30 +00:00
1. [Install the and start ]({{< ref "start/RunningViaDocker.md" >}} ) an Ozone cluster.
2018-11-27 23:57:24 +00:00
2. [Download ](https://prometheus.io/download/#prometheus ) the prometheus binary.
## Monitoring with prometheus
2019-08-21 17:17:41 +00:00
* To enable the Prometheus metrics endpoint you need to add a new configuration to the `ozone-site.xml` file.
2018-11-27 23:57:24 +00:00
2019-08-21 17:17:41 +00:00
```xml
2018-11-27 23:57:24 +00:00
< property >
< name > hdds.prometheus.endpoint.enabled< / name >
< value > true< / value >
< / property >
```
2019-08-21 17:17:41 +00:00
_Note_: for Docker compose based pseudo cluster put the \
`OZONE-SITE.XML_hdds.prometheus.endpoint.enabled=true` line to the `docker-config` file.
2018-11-27 23:57:24 +00:00
2019-08-21 17:17:41 +00:00
* Restart the Ozone Manager and Storage Container Manager and check the prometheus endpoints:
2018-11-27 23:57:24 +00:00
* http://scm:9874/prom
* http://ozoneManager:9876/prom
2019-08-21 17:17:41 +00:00
* Create a prometheus.yaml configuration with the previous endpoints:
2018-11-27 23:57:24 +00:00
```yaml
global:
2019-08-21 17:17:41 +00:00
scrape_interval: 15s
2018-11-27 23:57:24 +00:00
scrape_configs:
- job_name: ozone
metrics_path: /prom
static_configs:
- targets:
- "scm:9876"
- "ozoneManager:9874"
```
2019-08-21 17:17:41 +00:00
* Start with prometheus from the directory where you have the prometheus.yaml file:
2018-11-27 23:57:24 +00:00
2019-08-21 17:17:41 +00:00
```bash
2018-11-27 23:57:24 +00:00
prometheus
```
2019-08-21 17:17:41 +00:00
* Check the active targets in the prometheus web-ui:
2018-11-27 23:57:24 +00:00
http://localhost:9090/targets
2019-04-29 20:28:19 +00:00
![Prometheus target page example ](prometheus.png )
2018-11-27 23:57:24 +00:00
2019-08-21 17:17:41 +00:00
* Check any metrics on the prometheus web ui.\
For example:
2018-11-27 23:57:24 +00:00
http://localhost:9090/graph?g0.range_input=1h& g0.expr=om_metrics_num_key_allocate& g0.tab=1
2019-06-28 22:59:33 +00:00
![Prometheus metrics page example ](prometheus-key-allocate.png )
2018-11-27 23:57:24 +00:00
## Note
The ozone distribution contains a ready-to-use, dockerized environment to try out ozone and prometheus. It can be found under `compose/ozoneperf` directory.
```bash
cd compose/ozoneperf
docker-compose up -d
```