{"id":4367,"date":"2022-03-03T15:27:16","date_gmt":"2022-03-03T21:27:16","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4367"},"modified":"2023-02-08T15:35:07","modified_gmt":"2023-02-08T21:35:07","slug":"setting-up-grafana-on-librenms","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/setting-up-grafana-on-librenms\/","title":{"rendered":"Setting up Grafana on LibreNMS"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Thanks to the guys who put together the information at the following links. <\/p>\n\n\n\n<p><a href=\"https:\/\/wadman.co.nz\/2021\/01\/02\/Viewing-LibreNMS-data-in-Grafana\/\">https:\/\/wadman.co.nz\/2021\/01\/02\/Viewing-LibreNMS-data-in-Grafana\/<\/a><br><a href=\"https:\/\/www.reddit.com\/r\/LibreNMS\/comments\/ojc8cc\/how_to_almost_natively_integrate_librenms_and\/\">https:\/\/www.reddit.com\/r\/LibreNMS\/comments\/ojc8cc\/how_to_almost_natively_integrate_librenms_and\/<\/a><\/p>\n\n\n\n<p>I ran into some issues trying to get this to work.  So here are some of my notes.  I already had a LibreNMS installation set up.  <\/p>\n\n\n\n<p><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install RRDReST\n<ol class=\"wp-block-list\">\n<li>Install Docker<\/li>\n\n\n\n<li>Configure Docker compose file<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Configure LibreNMS API User and Key<\/li>\n\n\n\n<li>Set up and Configure Grafana\n<ol class=\"wp-block-list\">\n<li>Install Grafana<\/li>\n\n\n\n<li>Install JSON Data Source Plugin<\/li>\n\n\n\n<li>Add LibreNMS API Data Source<\/li>\n\n\n\n<li>Add RRDReST Data Source<\/li>\n\n\n\n<li>Import Dashboard into Grafana<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>View graphs<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Installing RRDReST<\/h1>\n\n\n\n<p>NOTE FOR CENTOS 8, ALMALINUX 8 and 9<br>The steps for installing RRDReST are slightly different.  Check out the following post.<br><a href=\"https:\/\/www.incredigeek.com\/home\/setting-up-rrdrest-on-centos-8-or-almalinux-9\/\">https:\/\/www.incredigeek.com\/home\/setting-up-rrdrest-on-centos-8-or-almalinux-9\/<\/a><\/p>\n\n\n\n<p>I had issues installing RRDReST.  I am guessing it had to do with it accessing files.  I was able to install it in a docker container. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install Docker<\/li>\n\n\n\n<li>Create a compose file<\/li>\n\n\n\n<li>Install container<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Install docker<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo yum install -y docker docker-compose<br>sudo systemctl enable docker<\/pre>\n\n\n\n<p>Create docker compose file with the following options<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi docker-compose.yml<\/pre>\n\n\n\n<p>Change the TZ to your time zone.  If you have issues with the graphs, most likely something is off with the time zone between this container and Grafana\/LibreNMS server<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">version: \"3.5\"\n\nservices:\n\n  rrdrest:\n    image: michaelwadman\/rrdrest:latest\n    container_name: rrdrest\n    restart: always\n    volumes:\n      - \"\/opt\/librenms:\/opt\/librenms\"\n    environment:\n      - TZ=America\/Denver<\/pre>\n\n\n\n<p>Save the file and start and setup the container with <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo docker-compose up -d<\/pre>\n\n\n\n<p>You will need your docker container IP address to setup the connection in Grafana<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo docker exec -it rrdrest ip addr | grep eth0<\/pre>\n\n\n\n<p>Congratulations.  You should now have a RRDReST docker container that will auto start on system boot and has the correct time zone.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Configure LibreNMS API User and Key<\/h1>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a Grafana user in LibreNMS. (Settings Gear -&gt; Manage Users -&gt; Add Users)<br><em>You could technically skip this step and use an existing user.<\/em><\/li>\n\n\n\n<li>Create API token for the newly created user (Setting Gear -&gt; API -&gt; API Settings)<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"809\" height=\"733\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image.png\" alt=\"\" class=\"wp-image-4374\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image.png 809w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-300x272.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-768x696.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-331x300.png 331w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/a><figcaption class=\"wp-element-caption\">Create a Grafana user in LibreNMS<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"297\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-1.png\" alt=\"\" class=\"wp-image-4375\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-1.png 602w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-1-300x148.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-1-500x247.png 500w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><figcaption class=\"wp-element-caption\">Setup API Key for Grafana in LibreNMS<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Set up and Configure Grafana<\/h1>\n\n\n\n<p>Basic steps are as follows<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install Grafana<\/li>\n\n\n\n<li>Install JSON Data Source Plugin<\/li>\n\n\n\n<li>Configure Data Sources\n<ol class=\"wp-block-list\">\n<li>LibreNMS API<\/li>\n\n\n\n<li>RRDRest API<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Import Dashboard into Grafana<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Install Grafana <\/h2>\n\n\n\n<p>There is not anything special with installing Grafana on the same server as LibreNMS.  You can follow the official guide to install it <\/p>\n\n\n\n<p><a href=\"https:\/\/grafana.com\/docs\/grafana\/latest\/installation\/\">https:\/\/grafana.com\/docs\/grafana\/latest\/installation\/<\/a><\/p>\n\n\n\n<p>After Grafana is installed, install the <a href=\"https:\/\/grafana.com\/grafana\/plugins\/marcusolsson-json-datasource\/\">JSON API<\/a> data source.  You can do this using the grafana-cli<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grafana-cli plugins install marcusolsson-json-datasource<\/pre>\n\n\n\n<p><em>A note on SSL\/TLS certificates.  If you have an SSL certificate for LibreNMS, you can use it for grafana.  If you run into issues, try copying the cert (fullchain.pem, privkey.pem) to \/etc\/grafana\/<\/em><\/p>\n\n\n\n<p><em>You&#8217;ll most likely need to change owner<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo chown root:grafana \/etc\/grafana\/*.pem<\/pre>\n\n\n\n<p><em>And maybe the file permissions.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo chmod 640 \/etc\/grafana\/*.pem<\/pre>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Install JSON Data Source Plugin<\/h2>\n\n\n\n<p>This is fairly straight forward.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grafana-cli plugins install marcusolsson-json-datasource<\/pre>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Add LibreNMS API Data Source<\/h2>\n\n\n\n<p>In Grafana, go to Configuration -&gt; Data Sources -&gt; Add data source<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set Name for Data Source<\/li>\n\n\n\n<li>URL should be https:\/\/your_librenms_url\/api\/v0<\/li>\n\n\n\n<li>Add Custom HTTP Header\n<ul class=\"wp-block-list\">\n<li>Header field should be &#8220;X-Auth-Token&#8221;<\/li>\n\n\n\n<li>Value field should contain the API token we created in LibreNMS<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Save and Test<br>  <em>If you receive any errors, refer to the Troubleshooting part at the end.<\/em><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"862\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-4.png\" alt=\"\" class=\"wp-image-4378\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-4.png 634w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-4-221x300.png 221w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/a><figcaption class=\"wp-element-caption\">Adding LibreNMS API Data Source in Grafana<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\"><strong>Add RRDReST Data Source<\/strong><\/h2>\n\n\n\n<p>In Grafana, go to Configuration -&gt; Data Sources -&gt; Add data source<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set Name for Data Source<\/li>\n\n\n\n<li>URL needs to be your docker container IP address (Steps above)<\/li>\n\n\n\n<li>Save and Test (Should return &#8220;Unprocessable Entity&#8221;)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"584\" height=\"934\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-5.png\" alt=\"\" class=\"wp-image-4379\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-5.png 584w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-5-188x300.png 188w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><figcaption class=\"wp-element-caption\">Adding RRDReST API Data Source in Grafana<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h2 class=\"wp-block-heading\">Import Dashboard into Grafana<\/h2>\n\n\n\n<p>Now we need a dashboard to present our data. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to Create -&gt; Import<\/li>\n\n\n\n<li>Upload JSON file (Download from <a href=\"https:\/\/incredigeek.com\/home\/downloads\/LibreNMS_RRDReST_Grafana_Dashboard.json\">here<\/a> or <a href=\"https:\/\/pastebin.com\/Bt2n0QgL\">PasteBin<\/a> )<\/li>\n\n\n\n<li>Under RRDReST API , select our RRDReST Data Source<\/li>\n\n\n\n<li>Under LibreNMS API , select our LibreNMS Data Source<\/li>\n\n\n\n<li>Click Import<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"596\" height=\"560\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-6.png\" alt=\"\" class=\"wp-image-4380\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-6.png 596w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-6-300x282.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-6-319x300.png 319w\" sizes=\"auto, (max-width: 596px) 100vw, 596px\" \/><\/a><\/figure>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>You should now be able to view your dashboard and use the drop down menus to select devices<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"404\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7-1024x404.png\" alt=\"\" class=\"wp-image-4381\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7-1024x404.png 1024w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7-300x118.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7-768x303.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7-1536x606.png 1536w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7-500x197.png 500w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-7.png 1840w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Grafana viewing bandwidth on device being monitored by LibreNMS<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Troubleshooting<\/h1>\n\n\n\n<p>There were a couple of issues I ran into while trying to get everything working together.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>RRDReST shows 404 Not Found<\/strong><\/h2>\n\n\n\n<p>Issue: When trying to run RRDReST with uvicorn, I was never able to access the rrd files, even the test rrd files that are included when installing RRDReST.  I am guessing it is either a permisions issue, or something unable to access the files. <br>Work around: Install RRDReST via Docker container.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"170\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8-1024x170.png\" alt=\"\" class=\"wp-image-4385\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8-1024x170.png 1024w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8-300x50.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8-768x128.png 768w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8-500x83.png 500w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-8.png 1148w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Error Running uvicorn RRDReST<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Error Adding LibreNMS API<\/h2>\n\n\n\n<p>Issue: Get a &#8220;JSON API: Bad Request&#8221; when trying to set up the LibreNMS API Data Source in Grafana.<\/p>\n\n\n\n<p>Work around:  Install a valid SSL Certificate and set up a DNS record so you can access LibreNMS at librenms.yourdomain.com.<\/p>\n\n\n\n<p>More info: I would assume that &#8220;Skip TLS Verify&#8221; would work with or without a valid certificate, but it would not work for me.  There are potentially some other options with modifying how Nginx or Apache is set up that would get this working.  If you setup Grafana to use a SSL certificate, you may need to copy the certificate files (fullchain.pem, privkey.pem) to \/etc\/grafana\/ and run &#8220;chown root:grafana *.pem&#8221; to let grafana have access to the files.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"645\" height=\"834\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-3.png\" alt=\"\" class=\"wp-image-4377\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-3.png 645w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2022\/03\/image-3-232x300.png 232w\" sizes=\"auto, (max-width: 645px) 100vw, 645px\" \/><\/a><figcaption class=\"wp-element-caption\">Grafana LibreNMS API JSON API: Bad Request<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to the guys who put together the information at the following links. https:\/\/wadman.co.nz\/2021\/01\/02\/Viewing-LibreNMS-data-in-Grafana\/https:\/\/www.reddit.com\/r\/LibreNMS\/comments\/ojc8cc\/how_to_almost_natively_integrate_librenms_and\/ I ran into some issues trying to get this to work. So here are some of my notes. I already had a LibreNMS installation set up. &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/setting-up-grafana-on-librenms\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[352],"tags":[1286,1287,246,1284,353,134,389,1285],"class_list":["post-4367","post","type-post","status-publish","format-standard","hentry","category-librenms","tag-api","tag-data-source","tag-docker","tag-grafana","tag-librenms","tag-monitoring","tag-nms","tag-rrdrest"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4367"}],"version-history":[{"count":16,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4367\/revisions"}],"predecessor-version":[{"id":4827,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4367\/revisions\/4827"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}