{"id":3442,"date":"2021-09-13T12:05:36","date_gmt":"2021-09-13T12:05:36","guid":{"rendered":"https:\/\/www.petecodes.co.uk\/?p=3442"},"modified":"2021-09-13T12:17:10","modified_gmt":"2021-09-13T12:17:10","slug":"configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana","status":"publish","type":"post","link":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/","title":{"rendered":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana"},"content":{"rendered":"\n

When implementing Azure IoT solutions, we’re used to using the excellent Azure Monitor<\/a> service to surface metrics around our IoT Devices and Services.<\/p>\n\n\n\n

\"\"<\/a>
Azure IoT Hub Azure Monitor<\/figcaption><\/figure><\/div>\n\n\n\n

For IoT Edge devices however, we need to perform a few configuration steps to enable us to Gather metrics.<\/p>\n\n\n\n

For my particular solution, I’ll be using a Raspberry Pi as my IoT Edge device, however these instructions will work for most Linux implementations that support Prometheus and Grafana.<\/p>\n\n\n\n

Configure IoT Edge Metrics<\/h2>\n\n\n\n

The IoT Edge runtime modules automatically collect and surface metrics using the Prometheus Exposition Format.<\/p>\n\n\n\n

The EdgeAgent and EdgeHub modules both expose these metrics, accessible using a web browser. on port 9600 within the Edge Runtime.<\/p>\n\n\n\n

However, In order to have access to these two sets of Metrics, we need to map the individual port 9600 from each Module to an external port. <\/p>\n\n\n\n

In order to map the metrics ports, we modify the IoT Edge Deployment Manifest file, adding the relevant exposed ports and Mapping port 9600 on each module to a free public facing port.<\/p>\n\n\n\n

As a note, I’ll be using VS Code<\/a> and the IoT Tools extension<\/a> to manage the editing and deployment of the changes we’re going to make, but it’s also possible to carry out some of these steps directly in the portal if you so wish.<\/p>\n\n\n\n

Here’s an example IoT Edge Deployment Template;<\/p>\n\n\n\n

{\n  "$schema-template": "2.0.0",\n  "modulesContent": {\n    "$edgeAgent": {\n      "properties.desired": {\n        "schemaVersion": "1.0",\n        "runtime": {\n          "type": "docker",\n          "settings": {\n            "minDockerVersion": "v1.25",\n            "loggingOptions": "",\n            "registryCredentials": {\n              "pjgiotedgedevops": {\n                "username": "$CONTAINER_REGISTRY_USERNAME_pjgiotedgedevops",\n                "password": "$CONTAINER_REGISTRY_PASSWORD_pjgiotedgedevops",\n                "address": "pjgiotedgedevops.azurecr.io"\n              }\n            }\n          }\n        },\n        "systemModules": {\n          "edgeAgent": {\n            "type": "docker",\n            "settings": {\n              "image": "mcr.microsoft.com\/azureiotedge-agent:1.0",\n              "createOptions": {\n\n              }\n            }\n          },\n          "edgeHub": {\n            "type": "docker",\n            "status": "running",\n            "restartPolicy": "always",\n            "settings": {\n              "image": "mcr.microsoft.com\/azureiotedge-hub:1.0",\n              "createOptions": {\n                "HostConfig": {\n                  "PortBindings": {\n                    "5671\/tcp": [\n                      {\n                        "HostPort": "5671"\n                      }\n                    ],\n                    "8883\/tcp": [\n                      {\n                        "HostPort": "8883"\n                      }\n                    ],\n                    "443\/tcp": [\n                      {\n                        "HostPort": "443"\n                      }\n                    ]\n                  }\n                }\n              }\n            }\n          }\n        },\n        "modules": {\n          "NodeModule": {\n            "version": "66.0",\n            "type": "docker",\n            "status": "running",\n            "restartPolicy": "always",\n            "settings": {\n              "image": "${MODULES.NodeModule.debug}",\n              "createOptions": {\n               \n              }\n            }\n          },\n          "SimulatedTemperatureSensor": {\n            "version": "1.0",\n            "type": "docker",\n            "status": "running",\n            "restartPolicy": "always",\n            "settings": {\n              "image": "mcr.microsoft.com\/azureiotedge-simulated-temperature-sensor:1.0",\n              "createOptions": {}\n            }\n          }\n        }\n      }\n    },\n    "$edgeHub": {\n      "properties.desired": {\n        "schemaVersion": "1.0",\n        "routes": {\n          "NodeModuleToIoTHub": "FROM \/messages\/modules\/NodeModule\/outputs\/* INTO $upstream",\n          "sensorToNodeModule": "FROM \/messages\/modules\/SimulatedTemperatureSensor\/outputs\/temperatureOutput INTO BrokeredEndpoint(\\"\/modules\/NodeModule\/inputs\/input1\\")"\n        },\n        "storeAndForwardConfiguration": {\n          "timeToLiveSecs": 7200\n        }\n      }\n    }\n  }\n}<\/code><\/pre><\/div>\n\n\n\n

On lines 26 and 37, we can see the “createOptions” sections. These are the sections we need to modify in order to map the required ports for our Metrics.<\/p>\n\n\n\n

We can see part of the section already exists for the edgeHub module beginning on line 37, where the ports for SSL (443), AMQP (5671) and MQTT (8883) are all mapped for us.<\/p>\n\n\n\n

We need to map port 9600 to a port for each of the edgeAgent and edgeHub and expose these ports out from IoT Edge so we can access them.<\/p>\n\n\n\n

We can achieve that for the edgeAgent by adding the following code snippet to the createOptions for this module on line 27;<\/p>\n\n\n\n

"ExposedPorts": {\n    "9600\/tcp": {}\n},\n"HostConfig": {\n    "PortBindings": {\n        "9600\/tcp": [\n            {\n                "HostPort": "9601"\n            }\n        ]\n    }\n}<\/code><\/pre><\/div>\n\n\n\n

We now need to repeat this for the edgeHub Module. However, as we can see, there are already some port mappings defined here. <\/p>\n\n\n\n

You can either add the required port mapping in to what you already have, or, assuming you’ve not made any modifications yourself, replace the createOptions section for the edgeHub with the following, where we’ve added the Exposed Ports and the binding for port 9600 mapping it to port 9602;<\/p>\n\n\n\n

"ExposedPorts": {\n    "9600\/tcp": {}\n},\n"HostConfig": {\n    "PortBindings": {\n        "5671\/tcp": [\n            {\n                "HostPort": "5671"\n            }\n        ],\n        "8883\/tcp": [\n            {\n                "HostPort": "8883"\n            }\n        ],\n        "443\/tcp": [\n            {\n                "HostPort": "443"\n            }\n        ],\n        "9600\/tcp": [\n            {\n                "HostPort": "9602"\n            }\n        ]\n    }\n}<\/code><\/pre><\/div>\n\n\n\n

We’ve now mapped port 9600 on both the edgeAgent and edgeHub modules to 9601 and 9602 respectively, allowing us to access them from a browser.<\/p>\n\n\n\n

Create an IoT Edge Deployment<\/h2>\n\n\n\n

We now need to update our IoT Edge device based on our new Deployment Manifest<\/p>\n\n\n\n

Once again, I’ll be using VS Code<\/a> and the IoT Tools Extension<\/a> here, but you can also paste the create options settings into the “Container Create Options” for the Runtime Settings of your IoT Edge Device. These can be access by navigating to your IoT Edge Device in IoT Hub, then to the “Set Modules” blade, and clicking on the “Runtime Settings” button under “IoT Edge Modules”;<\/p>\n\n\n\n

\"\"<\/a>
Runtime Settings – Container Create Options<\/figcaption><\/figure><\/div>\n\n\n\n

From VS Code, assuming that you’ve completed the setup of the IoT Tools Extension, selected the correct Azure Subscription, IoT Hub for your IoT Device and configured the default deployment platform, we can right click on our Deployment Template and create a Deployment Manifest;<\/p>\n\n\n\n

\"\"<\/a>
VS Code – Generate Deployment Manifest<\/figcaption><\/figure><\/div>\n\n\n\n

Once the Deployment Manifest is generated, we can then deploy the changes to our IoT Device.<\/p>\n\n\n\n

Right click on your IoT Edge Device and select “Create Deployment for Single Device”;<\/p>\n\n\n\n

\"\"<\/a>
VS Code – Create Deployment for Single Device<\/figcaption><\/figure><\/div>\n\n\n\n

In the File Picker, navigate to your config directory, and select the deployment.json file (or the name of your deployment json file, which may be named platform specifically, such as deployment.arm23v7.json for instance).<\/p>\n\n\n\n

View the Raw Metrics<\/h2>\n\n\n\n

After a small wait for the IoT Edge device to update the Modules on the device, (you can check the progress by issuing the docker ps -a command, or by using the portal to check the status of the modules), we can then open a browser and navigate to the pages for the raw metrics.<\/p>\n\n\n\n

If we navigate to the IP address of our IoT Edge Device and add :9601<\/em><\/strong>, then we’ll see the raw metrics for the edgeAgent Module;<\/p>\n\n\n\n

\"\"<\/a>
IoT Edge edgeAgent Module Metrics<\/figcaption><\/figure><\/div>\n\n\n\n

Likewise, if we navigate to our IoT Edge Device IP address and add :9602<\/em><\/strong>, then we’ll see the raw metrics for the edgeHub Module;<\/p>\n\n\n\n

\"\"<\/a>
IoT Edge edgeHub Module Metrics<\/figcaption><\/figure><\/div>\n\n\n\n

Add the Metrics Feeds to Prometheus<\/h2>\n\n\n\n

My particular IoT Edge solution uses a Raspberry Pi<\/p>\n\n\n\n

If you haven’t already installed Prometheus, then there’s an excellent tutorial here on the PiMyLifeUp site;<\/p>\n\n\n\n

https:\/\/pimylifeup.com\/raspberry-pi-prometheus\/<\/a><\/p>\n\n\n\n

Once you have Prometheus installed and configured, we need to add the two Metrics Feeds as new Nodes in our Prometheus installation.<\/p>\n\n\n\n

Using the following command, open the Prometheus configuration file;<\/p>\n\n\n\n

nano \/home\/pi\/prometheus\/prometheus.yml<\/code><\/pre><\/div>\n\n\n\n

Scroll down and find the “scrape_configs” section;<\/p>\n\n\n\n

# A scrape configuration containing exactly one endpoint to scrape:\n# Here it's Prometheus itself.\nscrape_configs:\n  # The job name is added as a label `job=<job_name>` to any timeseries scraped$\n  - job_name: 'prometheus'\n\n    # metrics_path defaults to '\/metrics'\n    # scheme defaults to 'http'.\n\n    static_configs:\n    - targets: ['localhost:9090']<\/code><\/pre><\/div>\n\n\n\n

Beneath the last “static_configs” item, add the following lines to include our Metrics feeds;<\/p>\n\n\n\n

  - job_name: 'iotedge_agent'\n\n    static_configs:\n    - targets: ['localhost:9601']\n\n  - job_name: 'iotedge_hub'\n\n    static_configs:\n    - targets: ['localhost:9602']<\/code><\/pre><\/div>\n\n\n\n

Save and Exit using “ctrl+x” and then “y” followed by hitting enter.<\/p>\n\n\n\n

Restart to the Prometheus service using;<\/p>\n\n\n\n

sudo systemctl restart prometheus<\/code><\/pre><\/div>\n\n\n\n

We can now check if Prometheus is picking up our feeds correctly.<\/p>\n\n\n\n

Navigate to your Prometheus Instance, and under the Status” menu Item, select “Targets”;<\/p>\n\n\n\n

\"\"<\/a>
Prometheus – Targets Menu Item<\/figcaption><\/figure><\/div>\n\n\n\n

You should then see all the configured targets, and all being well, the edgeAgent and edgeHub targets should be showing as “UP”;<\/p>\n\n\n\n

\"\"<\/a>
Prometheus – Targets<\/figcaption><\/figure><\/div>\n\n\n\n

Configure Grafana<\/h2>\n\n\n\n

Finally, now that we have Prometheus configured to grab our Metrics feeds, we can configure Grafana to show some of them on a Dashboard.<\/p>\n\n\n\n

If you haven’t already installed Grafana, there’s a great tutorial on the Grafana Website here;<\/p>\n\n\n\n

https:\/\/grafana.com\/tutorials\/install-grafana-on-raspberry-pi\/<\/a><\/p>\n\n\n\n

Once you have Grafana set up and configured, we need to add our Prometheus Data Source.<\/p>\n\n\n\n

Hover over the Configuration gear icon and select the “Data sources” item;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Data Sources<\/figcaption><\/figure><\/div>\n\n\n\n

Next click the “Add data source” button;<\/p>\n\n\n\n

\"\"<\/a><\/figure><\/div>\n\n\n\n

We’ll be shown a list of “Time series databases” to choose from. Select the “Prometheus” option;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Select Prometheus Data Source Option<\/figcaption><\/figure><\/div>\n\n\n\n

Give your Data Source a name, for instance “Prometheus”, and set the URL to be the same as the Prometheus URL, leaving the Access” as “Server (default)”;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Setup Prometheus Data Source<\/figcaption><\/figure><\/div>\n\n\n\n

Leave all the other options at their defaults and hit the “Save & test” button to check that everything is working correctly;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Save and Test Data Source<\/figcaption><\/figure><\/div>\n\n\n\n

Create a Simple Grafana Dashboard<\/h2>\n\n\n\n

With our Prometheus Data Source configured, we can now create a simple dashboard to bring in some of basic metrics from our IoT Edge installation.<\/p>\n\n\n\n

If you hover over the Dashboards icon and select “Manage”;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Manage Dashboards Menu Icon<\/figcaption><\/figure><\/div>\n\n\n\n

We then then click the “New Dashboard” button to begin creating our new Dashboard;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – New Dashboard Button<\/figcaption><\/figure><\/div>\n\n\n\n

We’ll then be shown the “New dashboard” screen, where we can add our first panel by pressing the “Add an empty panel” button;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Add an empty panel button<\/figcaption><\/figure><\/div>\n\n\n\n

We’ll then be shown the panel options, including the Panel Options on the right and the “PromQL” query area at the bottom;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – New Panel Screen<\/figcaption><\/figure><\/div>\n\n\n\n

Let’s add a graph for the number of messages received. We can leave the Visualisation Type set to “Time series” on the right, and enter a Title of “Messages Received” along with a suitable description.<\/p>\n\n\n\n

To add a particular metric, we query it using the PromQL” query area at the bottom;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – PromQL Query Area<\/figcaption><\/figure><\/div>\n\n\n\n

If we type “edge” in the PromQL area, we’ll now start to see the list of IoT Edge Metrics available to us;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – IoT Edge Metrics List<\/figcaption><\/figure><\/div>\n\n\n\n

We’re interested in the total number of messages received by the edgeHub Module, so enter “edgehub_messages_received_total”.<\/p>\n\n\n\n

If we now hit “shift+enter”, our panel will update with a preview of the data;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Total Messages Received<\/figcaption><\/figure><\/div>\n\n\n\n

Save the new Panel by pressing the “Apply” button in the top right hand corner of the screen;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Apply Panel Changes<\/figcaption><\/figure><\/div>\n\n\n\n

Our dashboard will then show our Messages Received graph. We can have the dashboard automatically update the metrics it’s showing by clicking the Refresh Interval dropdown and selecting a suitable refresh rate… I’ve chosen 5 seconds here;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Messages Received Panel and Refresh Interval<\/figcaption><\/figure><\/div>\n\n\n\n

Next let’s add a Connected Clients metric, this will show the number of either connected devices or modules connected to our edgeHub Module.<\/p>\n\n\n\n

Click the New Panel icon in the top right menu and once again select “Add an empty panel”;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – New Panel<\/figcaption><\/figure><\/div>\n\n\n\n

This time we’ll just add a simple text readout of the metric. From the Visualisation Dropdown, select the “Stat” option;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Stat Visualisation Option<\/figcaption><\/figure><\/div>\n\n\n\n

Give the Panel a Title of “Number of Connected Devices” and a suitable description. Then scroll down to the “Graph mode” options and select the “None” option to remove the graph;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Stat Visualisation Options<\/figcaption><\/figure><\/div>\n\n\n\n

In the PromQL area, enter “edgehub_connected_clients”, then hit the “Apply” button in the top right to add the panel to our dashboard. You can grab the corner of the panel to resize it if you like too;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Dashboard showing Number of Connected Clients<\/figcaption><\/figure>\n\n\n\n

As a note, we’re showing a value of 2 for the number of Connected Clients, as we have two modules connected to the edgeHub module. We can see this if we view the module twin for the edgeHub. We can do this by expanding the IoT Edge Device in the Azure IoT Hub section of VS Code, expanding the Modules section, then right clicking on the “$edgeHub” module and selecting “Edit Module Twin”;<\/p>\n\n\n\n

\"\"<\/a>
VS Code – Edit Module Twin Menu Item<\/figcaption><\/figure><\/div>\n\n\n\n

This will then show us the Module Twin for the edgeHub Module. If we scroll down to the “Reported Properties” section and to the “clients” section, we can see the connected clients. In my case I have a “NodeModule” client and a “SimulatedTemperatureSensor” client;<\/p>\n\n\n\n

\"\"<\/a>
VS Code – Edit module Twin – Clients<\/figcaption><\/figure><\/div>\n\n\n\n

Finally, let’s add a free CPU % gauge to our dashboard. Add another new empty panel using the “New Panel” icon in the menu and selecting “Add an empty panel”.<\/p>\n\n\n\n

Select “Gauge” from the Visualisation Options. <\/p>\n\n\n\n

We’ll now shortcut the creation of this panel by creating it using some JSON I’ve prepared.<\/p>\n\n\n\n

Click the “Query inspector” button to the right of the “Data source” panel;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Query Inspector Button<\/figcaption><\/figure><\/div>\n\n\n\n

Click the “JSON” option;<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

Remove the existing JSON and paste the following snippet of JSON in its place;<\/p>\n\n\n\n

{\n  "id": 23763571993,\n  "gridPos": {\n    "x": 7,\n    "y": 0,\n    "w": 5,\n    "h": 4\n  },\n  "type": "gauge",\n  "title": "Free CPU",\n  "pluginVersion": "8.1.3",\n  "targets": [\n    {\n      "expr": "edgeAgent_used_cpu_percent{quantile=\\"0.99\\",module_name=\\"host\\"}",\n      "legendFormat": "",\n      "interval": "",\n      "exemplar": true,\n      "refId": "A",\n      "instant": true,\n      "hide": true\n    },\n    {\n      "expr": "edgeAgent_used_cpu_percent{quantile=\\"0.99\\",module_name=\\"edgeAgent\\"}",\n      "legendFormat": "Edge Agent used CPU %",\n      "interval": "",\n      "exemplar": true,\n      "refId": "B",\n      "hide": true,\n      "instant": true\n    },\n    {\n      "expr": "edgeAgent_used_cpu_percent{quantile=\\"0.99\\",module_name=\\"edgeHub\\"}",\n      "legendFormat": "Edge Hub used CPU %",\n      "interval": "",\n      "exemplar": true,\n      "refId": "C",\n      "hide": true,\n      "instant": true\n    },\n    {\n      "refId": "D",\n      "type": "math",\n      "datasource": "__expr__",\n      "hide": false,\n      "expression": "$A - $B - $C"\n    }\n  ],\n  "options": {\n    "reduceOptions": {\n      "values": false,\n      "calcs": [\n        "lastNotNull"\n      ],\n      "fields": ""\n    },\n    "showThresholdLabels": false,\n    "showThresholdMarkers": true,\n    "text": {}\n  },\n  "fieldConfig": {\n    "defaults": {\n      "thresholds": {\n        "mode": "absolute",\n        "steps": [\n          {\n            "value": null,\n            "color": "green"\n          },\n          {\n            "value": 80,\n            "color": "red"\n          }\n        ]\n      },\n      "mappings": [],\n      "color": {\n        "mode": "thresholds"\n      },\n      "min": 0,\n      "max": 100\n    },\n    "overrides": []\n  },\n  "datasource": null\n}<\/code><\/pre><\/div>\n\n\n\n

We can now hit the “Apply” button and our panel preview will be shown;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – CPU Percent Panel<\/figcaption><\/figure>\n\n\n\n

The Query section won’t automatically update, however we’ve collected the CPU usage metrics from the edgeHub and edgeAgent Modules and subtracted them from the Host CPU Metric to give us the figure used by the runtime modules of our IoT Edge Solution;<\/p>\n\n\n\n

\"\"<\/a>
Grafana – Used CPU Percentage Panel<\/figcaption><\/figure>\n\n\n\n

Of course, you would need to also add in any other modules you have deployed to your IoT Edge Solution to make this figure accurate, but for demo purposes, this is fine.<\/p>\n\n\n\n

Click the blue Apply button to save the panel and you should now have a rudimentary DashBoard;<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

Go ahead and save your dashboard by clicking the Save Icon in the Menu and choosing a suitable name.<\/p>\n\n\n\n

For reference, you can find a reference for all of the IoT Edge Metrics here;<\/p>\n\n\n\n

https:\/\/docs.microsoft.com\/en-us\/azure\/iot-edge\/how-to-access-built-in-metrics?view=iotedge-2020-11&WT.mc_id=IoT-MVP-5003506<\/a><\/p>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

When implementing Azure IoT solutions, we’re used to using the excellent Azure Monitor service to surface metrics around our IoT…<\/p>\n","protected":false},"author":1,"featured_media":3493,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[41,11,40,42,13],"acf":[],"aioseo_notices":[],"yoast_head":"\nConfiguring and Visualising IoT Edge Metrics using Prometheus and Grafana - Pete Codes<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana\" \/>\n<meta property=\"og:description\" content=\"In this post I guide you through how to configure IoT Edge to expose metrics, then configure Prometheus and Grafana to show us a nice dashboard.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\" \/>\n<meta property=\"og:site_name\" content=\"Pete Codes\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-13T12:05:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-13T12:17:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"PeteCodes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana\" \/>\n<meta name=\"twitter:description\" content=\"In this post I guide you through how to configure IoT Edge to expose metrics, then configure Prometheus and Grafana to show us a nice dashboard.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"PeteCodes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\"},\"author\":{\"name\":\"PeteCodes\",\"@id\":\"https:\/\/www.petecodes.co.uk\/#\/schema\/person\/c2f636f242b064676ae61ed0022b32e7\"},\"headline\":\"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana\",\"datePublished\":\"2021-09-13T12:05:36+00:00\",\"dateModified\":\"2021-09-13T12:17:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\"},\"wordCount\":1950,\"publisher\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png\",\"keywords\":[\"Grafana\",\"IoT\",\"IoT Edge\",\"Prometheus\",\"Raspberry Pi\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\",\"url\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\",\"name\":\"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana - Pete Codes\",\"isPartOf\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png\",\"datePublished\":\"2021-09-13T12:05:36+00:00\",\"dateModified\":\"2021-09-13T12:17:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage\",\"url\":\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png\",\"contentUrl\":\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.petecodes.co.uk\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.petecodes.co.uk\/#website\",\"url\":\"https:\/\/www.petecodes.co.uk\/\",\"name\":\"Pete Codes\",\"description\":\"Pete Gallagher - Developer and Public Speaker\",\"publisher\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.petecodes.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.petecodes.co.uk\/#organization\",\"name\":\"Pete Codes\",\"url\":\"https:\/\/www.petecodes.co.uk\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.petecodes.co.uk\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2020\/06\/Logo-Small-Optimised.png\",\"contentUrl\":\"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2020\/06\/Logo-Small-Optimised.png\",\"width\":189,\"height\":100,\"caption\":\"Pete Codes\"},\"image\":{\"@id\":\"https:\/\/www.petecodes.co.uk\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.petecodes.co.uk\/#\/schema\/person\/c2f636f242b064676ae61ed0022b32e7\",\"name\":\"PeteCodes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.petecodes.co.uk\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/969dc1e441e755dd7d1f90da569dc913?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/969dc1e441e755dd7d1f90da569dc913?s=96&d=mm&r=g\",\"caption\":\"PeteCodes\"},\"sameAs\":[\"https:\/\/wordpress-634681-2064240.cloudwaysapps.com\"],\"url\":\"https:\/\/www.petecodes.co.uk\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana - Pete Codes","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/","og_locale":"en_US","og_type":"article","og_title":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana","og_description":"In this post I guide you through how to configure IoT Edge to expose metrics, then configure Prometheus and Grafana to show us a nice dashboard.","og_url":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/","og_site_name":"Pete Codes","article_published_time":"2021-09-13T12:05:36+00:00","article_modified_time":"2021-09-13T12:17:10+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png","type":"image\/png"}],"author":"PeteCodes","twitter_card":"summary_large_image","twitter_title":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana","twitter_description":"In this post I guide you through how to configure IoT Edge to expose metrics, then configure Prometheus and Grafana to show us a nice dashboard.","twitter_image":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png","twitter_misc":{"Written by":"PeteCodes","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#article","isPartOf":{"@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/"},"author":{"name":"PeteCodes","@id":"https:\/\/www.petecodes.co.uk\/#\/schema\/person\/c2f636f242b064676ae61ed0022b32e7"},"headline":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana","datePublished":"2021-09-13T12:05:36+00:00","dateModified":"2021-09-13T12:17:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/"},"wordCount":1950,"publisher":{"@id":"https:\/\/www.petecodes.co.uk\/#organization"},"image":{"@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage"},"thumbnailUrl":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png","keywords":["Grafana","IoT","IoT Edge","Prometheus","Raspberry Pi"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/","url":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/","name":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana - Pete Codes","isPartOf":{"@id":"https:\/\/www.petecodes.co.uk\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage"},"image":{"@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage"},"thumbnailUrl":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png","datePublished":"2021-09-13T12:05:36+00:00","dateModified":"2021-09-13T12:17:10+00:00","breadcrumb":{"@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#primaryimage","url":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png","contentUrl":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2021\/09\/Title-Image2.png","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/www.petecodes.co.uk\/configuring-and-visualising-iot-edge-metrics-using-prometheus-and-grafana\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.petecodes.co.uk\/"},{"@type":"ListItem","position":2,"name":"Configuring and Visualising IoT Edge Metrics using Prometheus and Grafana"}]},{"@type":"WebSite","@id":"https:\/\/www.petecodes.co.uk\/#website","url":"https:\/\/www.petecodes.co.uk\/","name":"Pete Codes","description":"Pete Gallagher - Developer and Public Speaker","publisher":{"@id":"https:\/\/www.petecodes.co.uk\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.petecodes.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.petecodes.co.uk\/#organization","name":"Pete Codes","url":"https:\/\/www.petecodes.co.uk\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.petecodes.co.uk\/#\/schema\/logo\/image\/","url":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2020\/06\/Logo-Small-Optimised.png","contentUrl":"https:\/\/www.petecodes.co.uk\/wp-content\/uploads\/2020\/06\/Logo-Small-Optimised.png","width":189,"height":100,"caption":"Pete Codes"},"image":{"@id":"https:\/\/www.petecodes.co.uk\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.petecodes.co.uk\/#\/schema\/person\/c2f636f242b064676ae61ed0022b32e7","name":"PeteCodes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.petecodes.co.uk\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/969dc1e441e755dd7d1f90da569dc913?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/969dc1e441e755dd7d1f90da569dc913?s=96&d=mm&r=g","caption":"PeteCodes"},"sameAs":["https:\/\/wordpress-634681-2064240.cloudwaysapps.com"],"url":"https:\/\/www.petecodes.co.uk\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/posts\/3442"}],"collection":[{"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/comments?post=3442"}],"version-history":[{"count":0,"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/posts\/3442\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/media\/3493"}],"wp:attachment":[{"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/media?parent=3442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/categories?post=3442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.petecodes.co.uk\/wp-json\/wp\/v2\/tags?post=3442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}