Docker + InfluxDB + Telegraf + Grafana


i am using OH3.1 within a docker container on my mac mini.
I want to log some KNX values and used grafana in the past.
Now i want to implement that in docker as well but i fail to do so.

I got influxdb as well as grafana installed and can access both in the browser.
In order to add a InfluxDB data source i need to install telegraf but i fail to do so.

Does anysone use Docker + Influx + Grafana and can help me set up my .yml?

Thank you!

Here’s what i have right now:

version: '2.2'

    image: influxdb:latest
    container_name: influxdb
      - 8086:8086
      - ./influxdb:/var/lib/influxdb
    restart: always

    image: grafana/grafana
    container_name: grafana
      - 3000:3000
      - influxdb
      - ./grafana:/var/lib/grafana
    restart: always

    image: telegraf:latest
    container_name: telegraf
        - influxdb
        - ./telegraf:/etc/telegraf/telegraf.conf:ro

i did not configure anything in the telegraf.conf (i don’t know how and what) - the docker dashboard says the telegraf container is created but its color is red.

I’m not familiar with telegraf. But it looks like you try to map a directory ./telegraf to a file /etc/telegraf/telegraf.conf. Or is telegraf a file without extension?

If you’re trying to graph KNX data gathered by OpenHAB and written to InfluxDB I can’t think why you’d need Telegraf. You should be able to add an InfluxDB datasource to straight into Grafana

oh wow. i totally didn’t see that even after checking twice …

that’s what i thought as well but i cannot create a standard influxdb datasource in the influxdb UI. it’s listet under telegraf plugins (see screenshots).

Is that a typo? You need to add the InfluxDB datasource in Grafana not in InfluxDB - unless i’m misunderstanding what you’re trying to do


in the past i followed this guide and got it working:

a DB is created there for openhab to write the data to and i thought i would have to do this manually in the influx ui?! maybe i can do it directly via docker though …

if i try to do it manually it tells me that i need telegraf … maybe that’s a thing in new influxdb versions …

I think the influx web UI is deprecated and unmaintained. I’ve never used it. You don’t need telegraf to create a database in influx though, for sure. I’d use the Influx commandline interface.

You can get a shell in your influx container

docker exec -it influxdb /bin/bash

Then use the commandline client to create a database

root@9d49bf5f5217:/# influx
Connected to http://localhost:8086 version 1.8.3
InfluxDB shell version: 1.8.3
> create database foo

thank you

if i type influx in the cli i get this output:

apply       Apply a template to manage resources
  auth        Authorization management commands
  backup      Backup database
  bucket      Bucket management commands
  completion  Generates completion scripts
  config      Config management commands
  dashboards  List Dashboard(s).
  delete      Delete points from influxDB
  export      Export existing resources as a template
  help        Help about any command
  org         Organization management commands
  ping        Check the InfluxDB /health endpoint
  query       Execute a Flux query
  restore     Restores a backup directory to InfluxDB.
  secret      Secret management commands
  setup       Setup instance with initial user, org, bucket
  stacks      List stack(s) and associated templates. Subcommands manage stacks.
  task        Task management commands
  telegrafs   List Telegraf configuration(s). Subcommands manage Telegraf configurations.
  template    Summarize the provided template
  transpile   Transpile an InfluxQL query to Flux source code
  user        User management commands
  v1          InfluxDB v1 management commands
  version     Print the influx CLI version
  write       Write points to InfluxDB

create is not an option

That looks to be InfluxDB 2, which I haven’t used. It looks to be very different to 1.x

This seems to be what you need. What was a database is now a bucket.

Then this for Grafana, in case helpful

1 Like

thanks i’ll give it a try tomorrow or maybe i can go back to v1.


i did manage to get influxdb and grafana running in my docker.
i also managed to install the influxdb add on and i think i configured it correctly vor v2.

do i even need telegraf? i quite don’t understand what that does. Or does openhab push data directly into the bucket?

I did it …
Telegraf is not needed at all.
i followed the guide here:

for v2 and it works flawlessly.

Just for clarity, Telegraf is an agent that gathers information about computers and software running on those servers and pushes the data to InfluxDB. Using InfluxDB + Telegraf + Grafana is one way to set up and configure monitoring of your IT assets. There are many other options including Prometheus, Zabbix, ELK stack, etc.

1 Like