Installation

Installation on Linux

Installation on RedHat and CentOS

  • Download influxDB for RedHat Linux from InfluxData Downloads, e.g.: https://download.influxdata.com/influxdb/releases/influxdb-1.11.8.x86_64.rpm

  • Copy file to server and Install influxdb: sudo rpm -ivh influxdb-1.11.8.x86_64.rpm

Installation on Docker

Dockerfile for all three services on the same container

# Use the official InfluxDB image
FROM influxdb:latest AS influxdb

# Use the official Telegraf image
FROM telegraf:latest AS telegraf

# Use the official Grafana image
FROM grafana/grafana:latest AS grafana

# Set up InfluxDB
FROM influxdb
COPY --from=influxdb /etc/influxdb/influxdb.conf /etc/influxdb/influxdb.conf
EXPOSE 8086

# Set up Telegraf
FROM telegraf
COPY --from=telegraf /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf
EXPOSE 8125/udp

# Set up Grafana
FROM grafana
COPY --from=grafana /etc/grafana/grafana.ini /etc/grafana/grafana.ini
EXPOSE 3000

# Start all services
CMD ["sh", "-c", "influxd & telegraf & grafana-server --homepath=/usr/share/grafana"]
  • If docker build shows error: file not found, try the following Dockerfile

Configuration

influxdb.conf

telegraf.conf

grafana.ini

Run docker

Docker compose for services in different containers

docker-compose.yml

Configuration

telegraf.conf

Run docker-compose

  • docker-compose up -d

Docker-compose for 2 containers: 1 for grafana and another one for influxdb and telegraf

Dockerfile

Docker-compose

Build and start services

API Commands

  • curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=telegraf" --data-urlencode "q=SELECT last("session_state") FROM "Cisco-IOS-XE-bgp-oper:bgp-state-data/neighbors/neighbor""

  • curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=telegraf" --data-urlencode "q=SELECT * FROM "Cisco-IOS-XE-bgp-oper:bgp-state-data/neighbors/neighbor""

  • curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=telegraf" --data-urlencode "q=SELECT * FROM interface where time > now() - 1m and source='$sourcename'" | jq -r ".results[].series[] | .columns,.values[] @csv"

  • curl -i XPOST "http://localhost:8086/write?db=telegraf" --data-binary 'cpu_load_short_host=serer01 value=0.64'

Access Database

  • influx -database telegraf -execute "show measurements"

  • influx -database telegraf -execute "select * from $table where time > now() -5m and host='$hostname'"

  • influx -database telegraf -execute "select * from "$tablewithspecialcharacter" where time > now() -5m and host='$hostname'"

Last updated