Skip to content

Commit

Permalink
Merge 42e6bdf into 7fcc785
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob-Naucke committed Aug 24, 2018
2 parents 7fcc785 + 42e6bdf commit f8bee18
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -84,7 +84,7 @@ If you want a quick "three simple metrics" setup with Prometheus and Grafana you
.. _Grafana: https://grafana.com/grafana/download
.. _Prometheus' guide on Grafana: https://prometheus.io/docs/visualization/grafana/

* Create the dashboard in Grafana. A `sample JSON`_ is provided.
* Create the dashboard in Grafana. A `sample JSON`_ is provided. If you want it to work natively, you will have to name your source ``ZHMC_Prometheus``.

.. _sample JSON: examples/grafana.json

Expand Down
2 changes: 1 addition & 1 deletion docs/intro.rst
Expand Up @@ -144,7 +144,7 @@ Demo setup
.. _Grafana: https://grafana.com/grafana/download
.. _Prometheus' guide on Grafana: https://prometheus.io/docs/visualization/grafana/

* Create the dashboard in Grafana. A sample JSON is provided in the examples folder. If you want to change something, you might find it easier to change it in the Web GUI instead of the JSON file.
* Create the dashboard in Grafana. A sample JSON is provided in the examples folder. If you want it to work natively, you will have to name your source ``ZHMC_Prometheus``. If you want to change something, you might find it easier to change it in the Web GUI instead of the JSON file.

The following image illustrates what the setup described above could look like.

Expand Down
4 changes: 2 additions & 2 deletions docs/usage.rst
Expand Up @@ -48,7 +48,7 @@ In the case of many of the metrics, they apply to multiple devices. The ``dpm``

Available metrics
-----------------
This is an easier to read version of the relevant parts from the `HMC Web Services API Documentation`_. On the first level, you can read the metric groups and their prefixes. On the second level, you can read the metrics and their exporter name without the prefix.
This is an easier to read version of the relevant parts from the `HMC Web Services API Documentation`_. On the first level, you can read the metric groups and their prefixes. They will additionally be prefixed with ``zhmc_``. On the second level, you can read the metrics and their exporter name without the prefix.

**Only in classic mode**

Expand Down Expand Up @@ -108,7 +108,7 @@ Example:
prefix: dpm
fetch: True
Within one section, the metric prefix and the fetch True/False value is stored. The latter is due to runtime concerns: Some metric groups take over a second to be scraped.
Within one section, the metric prefix and the fetch True/False value is stored. Note that the former will additionally be prefixed with ``zhmc_``. The latter is due to runtime concerns: Some metric groups take over a second to be scraped.

The metrics section
^^^^^^^^^^^^^^^^^^^
Expand Down
48 changes: 25 additions & 23 deletions examples/grafana.json
Expand Up @@ -15,23 +15,22 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 1,
"id": 2,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "myprometheus",
"datasource": "ZHMC_Prometheus",
"fill": 1,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"hideTimeOverride": false,
"id": 2,
"legend": {
"avg": false,
Expand All @@ -56,32 +55,28 @@
"steppedLine": false,
"targets": [
{
"$$hashKey": "object:172",
"expr": "dpm_processor_usage_ratio",
"expr": "zhmc_dpm_processor_usage_ratio",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "",
"refId": "A"
},
{
"$$hashKey": "object:173",
"expr": "dpm_storage_usage_ratio",
"expr": "zhmc_dpm_network_usage_ratio",
"format": "time_series",
"intervalFactor": 1,
"refId": "B"
},
{
"$$hashKey": "object:174",
"expr": "dpm_network_usage_ratio",
"expr": "zhmc_dpm_storage_usage_ratio",
"format": "time_series",
"intervalFactor": 1,
"refId": "C"
}
],
"thresholds": [],
"timeFrom": "2m",
"timeFrom": null,
"timeShift": null,
"title": "Testpanel",
"title": "IBM Z HMC Demo",
"tooltip": {
"shared": true,
"sort": 0,
Expand All @@ -97,16 +92,14 @@
},
"yaxes": [
{
"$$hashKey": "object:244",
"format": "percentunit",
"label": "Load in percent",
"label": null,
"logBase": 1,
"max": null,
"max": "0.1",
"min": "0",
"show": true
},
{
"$$hashKey": "object:245",
"format": "short",
"label": null,
"logBase": 1,
Expand All @@ -121,20 +114,29 @@
}
}
],
"refresh": "15s",
"refresh": "10s",
"schemaVersion": 16,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-5m",
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"15s"
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
Expand All @@ -148,8 +150,8 @@
"30d"
]
},
"timezone": "browser",
"title": "Z HMC Test",
"uid": "-AZc_Hviz",
"version": 3
"timezone": "",
"title": "IBM Z HMC",
"uid": "XcsuH8tik",
"version": 2
}
8 changes: 4 additions & 4 deletions zhmc_prometheus_exporter/test.py
Expand Up @@ -339,7 +339,7 @@ def test_add_families(self):
families = output["metric-group"]["metric"]
self.assertIsInstance(families,
prometheus_client.core.GaugeMetricFamily)
self.assertEqual(families.name, "pre_metric")
self.assertEqual(families.name, "zhmc_pre_metric")
self.assertEqual(families.documentation, "metric")
self.assertEqual(families.type, "gauge")
self.assertEqual(families.samples, [])
Expand All @@ -365,10 +365,10 @@ def test_store_metrics(self):
family_objects)
stored = output["metric-group"]["metric"]
self.assertIsInstance(stored, prometheus_client.core.GaugeMetricFamily)
self.assertEqual(stored.name, "pre_metric")
self.assertEqual(stored.name, "zhmc_pre_metric")
self.assertEqual(stored.documentation, "metric")
self.assertEqual(stored.type, "gauge")
self.assertEqual(stored.samples, [("pre_metric",
self.assertEqual(stored.samples, [("zhmc_pre_metric",
{"resource": "resource"},
0)])
self.assertEqual(stored._labelnames, ("resource",))
Expand Down Expand Up @@ -425,7 +425,7 @@ def test_collect(self):
self.assertEqual(len(collected), 1)
self.assertEqual(type(collected[0]),
prometheus_client.core.GaugeMetricFamily)
self.assertEqual(collected[0].name, "pre_metric")
self.assertEqual(collected[0].name, "zhmc_pre_metric")
self.assertEqual(collected[0].documentation, "metric")
self.assertEqual(collected[0].type, "gauge")
self.assertEqual(collected[0].samples, [])
Expand Down
5 changes: 4 additions & 1 deletion zhmc_prometheus_exporter/zhmc_prometheus_exporter.py
Expand Up @@ -301,7 +301,10 @@ def add_families(yaml_metric_groups, yaml_metrics):
for metric_group in yaml_metrics:
family_objects[metric_group] = {}
for metric in yaml_metrics[metric_group]:
family_name = (yaml_metric_groups[metric_group]["prefix"] + "_" +
family_name = ("zhmc_" +
yaml_metric_groups[metric_group]["prefix"]
+
"_" +
yaml_metrics[metric_group][metric]["exporter_name"])
family_objects[metric_group][metric] = GaugeMetricFamily(
family_name,
Expand Down

0 comments on commit f8bee18

Please sign in to comment.