{"id":28311080,"url":"https://github.com/odennav/grafana-telegraf-setup","last_synced_at":"2026-02-20T00:02:28.438Z","repository":{"id":242725143,"uuid":"810373782","full_name":"odennav/grafana-telegraf-setup","owner":"odennav","description":"System monitoring with telegraf, InfluxDB and grafana ","archived":false,"fork":false,"pushed_at":"2025-04-14T14:35:35.000Z","size":606,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T23:18:17.425Z","etag":null,"topics":["ansible","ansible-playbook","ansible-role","bash-scripting","grafana","grafana-dashboard","grafana-dashboards","influxdb","influxdb2","monitoring","monitoring-server","telegraf"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/odennav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-04T15:10:41.000Z","updated_at":"2025-04-20T16:32:58.000Z","dependencies_parsed_at":"2024-06-04T17:45:37.463Z","dependency_job_id":"2e0c5242-27e8-4b42-942c-16ba6f13b9e9","html_url":"https://github.com/odennav/grafana-telegraf-setup","commit_stats":{"total_commits":17,"total_committers":3,"mean_commits":5.666666666666667,"dds":0.2941176470588235,"last_synced_commit":"1b0b2b2c2bffe24485e46266b491a28b6a5ef9a3"},"previous_names":["odennav/grafana-telegraf-metrics-monitoring-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/odennav/grafana-telegraf-setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odennav%2Fgrafana-telegraf-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odennav%2Fgrafana-telegraf-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odennav%2Fgrafana-telegraf-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odennav%2Fgrafana-telegraf-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odennav","download_url":"https://codeload.github.com/odennav/grafana-telegraf-setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odennav%2Fgrafana-telegraf-setup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261248408,"owners_count":23130386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-playbook","ansible-role","bash-scripting","grafana","grafana-dashboard","grafana-dashboards","influxdb","influxdb2","monitoring","monitoring-server","telegraf"],"created_at":"2025-05-24T12:10:29.061Z","updated_at":"2026-02-20T00:02:28.432Z","avatar_url":"https://github.com/odennav.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grafana and Telegraf Metrics Monitoring  System\n\nGrafana is an open-source platform for monitoring and observability, primarily used to visualize time series data. It allows users to create and share dynamic dashboards, providing powerful and flexible visual representations of data.\n\nTelegraf is the plugin-driven server agent for collecting, processing, aggregating and writing metrics to InfluxDB.\n\nGrafana supports various data sources such as Prometheus, Graphite and OpenTSDB. In this lab we'll use InfluxDB as our preferred data source.\n\nInfluxDB is used as a data source for Grafana due to its high performance and scalability in handling large volumes of time-stamped data.\n\n![](https://github.com/odennav/grafana-telegraf-metrics-monitoring-system/blob/main/docs/Grafana-telegraf-influxdb.png)\n\n-----\n\n## Getting Started\n\n- Provision Servers with Terraform\n\n- User Configuration \n\n- Setup InfluxDB v2\n\n- Setup Telegraf\n\n- Install Grafana\n\n- Create Grafana Data Source\n\n- Import System Dashboard\n\n- Ansible Installation and Setup\n\n- Add Remote Hosts to Grafana Dasboard\n\n\n## Provision Servers with Terraform\n\nInstall AWS CLI in `local` machine\n```bash\nsudo apt install curl unzip\ncurl \"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\" -o \"awscliv2.zip\"\nunzip awscliv2.zip\nsudo ./aws/install -i /usr/local/aws-cli -b /usr/local/bin\n```\n\nConfirm the AWS CLI installation\n```bash\naws --version\n```\n\nClone this repository in the `local` machine\n```bash\ncd /\ngit clone git@github.com:odennav/grafana-telegraf-metrics-monitoring-system.git\n```\n\nExecute these Terraform commands sequentially in the `local` machine to create the AWS VPC(Virtual Private Cloud) and EC2 instances.\n\nInitializes terraform working directory\n```bash\ncd grafana-telegraf-metrics-monitoring-system/terraform\nterraform init\n```\n\nValidate the syntax of the terraform configuration files\n```bash\nterraform validate\n```\n\nCreate an execution plan that describes the changes terraform will make to the infrastructure\n```bash\nterraform plan\n```\n\nApply the changes described in execution plan\n```bash\nterraform apply -auto-approve\n```\n\nCheck AWS console for instances created and running\n\n**SSH access**\n\nUse `.pem` key from AWS to SSH into the public EC2 instance. IPv4 address of public EC2 instance will be shown in terraform outputs.\n```bash\nssh -i private-key/terraform-key.pem ec2-user@\u003cipaddress\u003e\n```\n\nWe can use public EC2 instance as a jumpbox to securely SSH into private EC2 instances within the VPC.\n\nNote, the ansible `inventory` is built dynamically by terraform with the private ip addresses of the `EC2` machines.\n\n-----\n\n## User Configuration \n\n**Add New User**\n\nWe'll use `central-server-1` virtual machine as our build machine.\n\nChange password for root user\n```bash\nsudo passwd\n```\n\nSwitch to root user. Add new user `odennav` to sudo group.\n```bash\nsudo useradd odennav\nsudo usermod -aG wheel odennav\n```\n\nNotice the prompt to enter your user password. To disable password prompt for every sudo command, implement the following:\n\nAdd sudoers file for odennav-admin\n\n```bash\necho \"odennav ALL=(ALL) NOPASSWD: ALL\" | sudo tee /etc/sudoers.d/odennav\n```\n\nEnsure correct permissions for sudoers file\n```bash\nsudo chmod 0440 /etc/sudoers.d/odennav\nsudo chown root:root /etc/sudoers.d/odennav\n```\n\nCreate new password for `odennav` user\n```bash\nsudo passwd odennav\n```\n\nTest sudo privileges by switching to new user\n\n```bash\nsu - odennav\nsudo ls -la /root\n```\n\nTo change the PermitRootLogin setting, modify the SSH server configuration file `/etc/ssh/sshd_config` as shown below:\n\n```text\nPermitRootLogin no\n```\n\nRestart the SSH service\n```bash\nsudo systemctl restart sshd.service\n```\n\nPlease note you'll have to repeat this user setup for each server provisioned.\n\n-----\n\n## Setup InfluxDB v2\n\nInstall InfluxDB as a service with systemd as shown below:\n\nDownload and install the appropriate `.rpm` file\n\n```bash\ncurl -LO https://download.influxdata.com/influxdb/releases/influxdb2-2.7.6-1.x86_64.rpm\nsudo yum localinstall -y influxdb2-2.7.6-1.x86_64.rpm\n```\n\nStart and enable the InfluxDB service\n\n```bash\nsudo systemctl start influxdb.service\nsudo systemctl enable influxdb.service\n```\n\nInstalling the InfluxDB package creates a service file at `/lib/systemd/system/influxdb.service` to start InfluxDB as a background service on startup.\n\nVerify the service is running\n\n```bash\nsudo systemctl status influxdb.service\n```\n\n**Setup Initial User of InfluxDB**\n\nImplement the following:\n\n- With InfluxDB running, visit `http://10.33.10.1:8086`.\n\n- Click `Get Started`.\n\n- Enter a `Username` for your initial user.\n\n- Enter a `Password` and `Confirm Password` for your user.\n\n- Enter your initial `Organization Name`.\n\n- Enter your initial `Bucket Name`.\n\n- Click `Continue`.\n\n- Copy the provided `operator API token` and store it for safe keeping.\n\nYour InfluxDB instance is now initialized.\n\n**Install Influx CLI**\n\nThe influx CLI is used to interact with and manage your InfluxDB instance.\n\nConfirm the cpu architecture of your local machine to\n```bash\nuname -m\nlscpu | grep Architecture\n```\n\nDownload the influx CLI package from the command line.\n```bash\nsudo wget https://download.influxdata.com/influxdb/releases/influxdb2-client-2.7.5-linux-amd64.tar.gz\n```\n\nUnpackage the downloaded binary\n```bash\ntar -xvzf ./influxdb2-client-2.7.5-linux-amd64.tar.gz\n```\n\n Place the unpackaged influx executable in system $PATH\n```bash\nsudo cp ./influx /usr/local/bin/\n```\n\nConfirm influx client is available\n```bash\ninflux version\n```\n\n**Create an All Access API token with influx CLI**\n\nWith the Operator token we can interact with InfluxDB, it's recommended to create an `All Access token` that is scoped to an organization, and then using this token to manage InfluxDB.\n\nUse the influx auth create command to create an All Access token\n\n```bash\ninflux auth create \\\n  --all-access \\\n  --host http://localhost:8086 \\\n  --org Treten \\\n  --token \u003cYOUR_INFLUXDB_OPERATOR_TOKEN\u003e\n```\n\nCopy the generated token and store it for safe keeping.\n\n\n**Configure authentication credentials**\n\nA connection configuration stores your credentials to avoid having to pass your InfluxDB API token with each influx command. \n\nIt specifies connection configuration presets to switch between InfluxDB connection credentials.\n\nUse the `All Access token` to interact with InfluxDB.\n\n```bash\ninflux config create \\\n  --config-name odennav-config \\\n  --host-url http://localhost:8086 \\\n  --org Treten \\\n  --token \u003cALL ACCESS API_TOKEN\u003e \\\n  --active\n```\n\nAuthenticate with a username and password\n```bash\ninflux config create \\\n  -n odennav-config \\\n  -u http://localhost:8086 \\\n  -p odennav:\u003cPASSWORD\u003e \\\n  -o Treten\n```\n\nSet the following environment variables\n```bash\nexport INFLUX_HOST=localhost:8086\nexport INFLUX_ORG=Treten\nexport INFLUX_ORG_ID=\u003cORG_ID\u003e\nexport INFLUX_TOKEN=\u003cALL ACCESS API_TOKEN\u003e\n```\n\n-----\n\n## Setup Telegraf\n\nUse the yum package manager to install the latest stable version of Telegraf\n\n```bash\ncat \u003c\u003cEOF | sudo tee /etc/yum.repos.d/influxdb.repo\n[influxdb]\nname = InfluxData Repository - Stable\nbaseurl = https://repos.influxdata.com/stable/\\$basearch/main\nenabled = 1\ngpgcheck = 1\ngpgkey = https://repos.influxdata.com/influxdata-archive_compat.key\nEOF\n```\n\nInstall Telegraf from the repo\n\n```bash\nsudo yum install -y telegraf\n```\n\nThe telegraf configuration file is installed at `/etc/telegraf/telegraf.conf`\n\nCreate a configuration file with default input and output plugins\n\n```bash\ntelegraf config \u003e /etc/telegraf/telegraf.conf\n```\n\nConfigure the input plugins\n\n   Search and uncomment the following plugins below to enable them in `telegraf.conf` file\n\n```text\n[[inputs.conntrack]]\n[[inputs.internal]]\n[[inputs.interrupts]]\n[[inputs.linux_sysctl_fs]]\n[[inputs.net]]\n[[inputs.netstat]]\n[[inputs.nstat]]\n```\n\n\nStart and enable Telegraf service\n\n```bash\nsudo systemctl start telegraf\nsudo systemctl enable telegraf\n```\n\nVerify the Telegraf service is running\n\n```bash\nsudo systemctl status telegraf.service\n```\n\nCheck databases in InfluxDB\n\n```bash\ninflux bucket list\n```\n\nLook at metrics/tables stored in the telegraf database\n```bash\ninflux query 'import \"influxdata/influxdb/schema\" schema.measurements(bucket: \"telegraf\")'\n```\n\nCheck data from swap measurement table\n```bash\ninflux query 'from(bucket: \"telegraf\")\n  |\u003e range(start: -1m)\n  |\u003e filter(fn: (r) =\u003e r._measurement == \"swap\")'\n```\n\n-----\n\n\n## Install Grafana\n\nTo install Grafana from the RPM repository, complete the following steps:\n\n```bash\nwget -q -O gpg.key https://rpm.grafana.com/gpg.key\nsudo rpm --import gpg.key\n```\n\nUse the yum package manager to install the latest stable version of Grafana\nAdd this to `/etc/yum/epos.d/grafana.repo`\n```bash\ncat \u003c\u003c EOF | sudo tee /etc/yum/epos.d/grafana.repo\n[grafana]\nname=grafana\nbaseurl=https://rpm.grafana.com\nrepo_gpgcheck=1\nenabled=1\ngpgcheck=1\ngpgkey=https://rpm.grafana.com/gpg.key\nsslverify=1\nsslcacert=/etc/pki/tls/certs/ca-bundle.crt\nEOF\n```\n\nInstall Grafana Enterprise\n```bash\nsudo yum install grafana-enterprise\n```\n\nTo start the grafana service\n```bash\nsudo systemctl daemon-reload\nsudo systemctl start grafana-server\n```\n\nTo configure the Grafana server to start at boot\n```bash\nsudo systemctl enable grafana-server.service\n```\n\nTo verify that the grafana service is running\n```\nsudo systemctl status grafana-server\n```\n\n-----\n\n## Create Grafana Data Source\n\nBrowse to `10.33.10.1:3000`.\n\nLog in with the username of `admin` and the password of `admin`\n\nImplement the following:\n\n- Click on the :gear: icon in the menu bar on the left. It will take you to the Configuration page for Grafana\n\n- Click on the `Add data sources` button\n\n- Click on `InfuxDB` as your choice of time series database.\n\n- Fill the `Settings` form as below:\n\n  Name ----------------\u003e InfluxDB-Telegraf\n  \n  Default--------------\u003e Click to turn the selector on.\n\n  Query Language ------\u003e InfluxQL\n\n  URL -----------------\u003e `http://localhost:8086`\n\n  Access --------------\u003e Server (default)\n\n  Database ------------\u003e telegraf\n\n\nClick the `Save \u0026 Test` button.\n\nNow Grafana can access the metrics stored in InfluxDB.\n\n-----\n\n## Import System Dashboard\n\nHover over the **`+`** sign in the menu on the left of your screen. It will expand into a menu when you hover over it.\n\nFrom there, click on `Import`.\n\nImplement the following:\n\n- In the `Grafana dashboard URL or id` field, enter `13095` and click the \"Load\" button next to it.\n\nAn alternative is to import a JSON file for the grafana dashboard.\n\nTo upload click `Upload JSON File` and navigate to `/grafana-metrics-monitoring-system/grafana templates/13095_System` in this repo. \n\nNote the`IPMI` json template available in this repo. It's an awesome SNMP based dashboard to monitor Dell hosts via iDRAC.\n\nTo use this dashboard you'll have to ensure `SNMPv1` is enabled in iDRAC and also enable the SNMP input plugin in `telegraf.conf` file as shown [here](https://grafana.com/grafana/dashboards/12106-idrac-host-stats/)\n\nTo view more dashboards, check [Grafana Labs](https://grafana.com/grafana/dashboards/)\n\n- On the next screen in the `Select an InfluxDB data source` box, select `InfluxDB-Telegraf`. Then click on the `Import` button.\n\nNow you should see a dashboard displaying system performance information for the grafana host.\n\nEnsure to save the imported dasboard.\n\n\n----- \n\n## Ansible Installation and Setup\n\nThe task of configuring a remote hosts as an icinga agents is repetitve.\n\nWe'll need to install and use ansible to ensure consisitent and efficient configuration.\n\n**Install Ansible**\n\nTo install ansibe without upgrading current python version, we'll make use of the yum package manager.\n\n```bash\nsudo yum update\n```\n\nInstall EPEL repository\n\n```bash\nsudo yum install epel-release\n```\n\nVerify installation of EPEL repository\n```bash\nsudo yum repolist\n```\n\nInstall Ansible\n```bash\nsudo yum install ansible\n```\n\nConfirm installation\n```bash\nansible --version\n```\n\n**Configure Ansible Vault**\n\nAnsible communicates with target remote servers using SSH and usually we generate `RSA` key pair and copy the public key to each remote server, instead we'll use username and password credentials of the `odennav` user.\n\nThis credentials are added to inventory host file but encrypted with ansible-vault.\n\nEnsure all IPv4 addresses and user variables of remote servers are in the inventory file.\n\nView `ansible-vault/values.yml` which has the secret password\n\n```bash\ncat /grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/values.yml\n```\n\nGenerate vault password file\n```bash\nopenssl rand -base64 2048 \u003e /grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/secret-vault.pass\n```\n\nCreate ansible vault with vault password file\n```bash\nansible-vault create /grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/values.yml --vault-password-file=/grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/secret-vault.pass\n```\n\nView content of ansible vault\n```bash\nansible-vault view /grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/values.yml --vault-password-file=/grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/secret-vault.pass\n```\n\nRead ansible vault password from environment variable\n```bash\nexport ANSIBLE_VAULT_PASSWORD_FILE=/grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/secret-vault.pass\n```\n\nConfirm environment variable has been exported\n```bash\nexport ANSIBLE_VAULT_PASSWORD_FILE\n```\n\nTest Ansible by pinging all remote servers in inventory list\n```bash\nansible all -m ping\n```\n\n-----\n\n## Add Remote Hosts to Grafana Dashboard\n\nProvision other remote hosts with Vagrant and implement new user configuration.\n\n\nUse ansible playbook `/ansible/deploy_telegraf/setup_telegraf.yml`\n```bash\nansible-playbook -i inventory /grafana-telegraf-metrics-monitoring-system/ansible/deploy_telegraf/deploy_telegraf.yml -e @/grafana-telegraf-metrics-monitoring-system/ansible/ansible-vault/values.yml\n```\n\nReturn to your web browser and reload the dashboard page.\n\nAt the top of your browser you should see a selector box for `Server`.  \n\nWhen you click on the word `Server` you will see the grafana VM, `central-server-1` as well as our newly added VMs.\n\n-----\n\nEnjoy!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodennav%2Fgrafana-telegraf-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodennav%2Fgrafana-telegraf-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodennav%2Fgrafana-telegraf-setup/lists"}