Telegraf / Server Hostname instead of id

Hi there,

I just deploy in my docker swarm (with caddy in reverseproxy role) and all is OK.
thanks to this guy : Grafana 8 - InfluxDB 2 - Telegraf - 2021 monitoring stack
It was very helpful.

Anyway, I have two questions.
1st question/ in my telegraf.conf for connect to influxdbv2 i must put my VIP ( delivered via keepalived container). http://192.168.0.41:8086
If i want to use container name like influxdb:8086 or the ingress ip like 172.17.0.1:8086 it doesn’t work. Dunno why. BTW the ingress ip is uses in my caddyfile with success.

2nd question/ when i browse my data in influxdb telegraf show servers id instead of servers hostname.
Maybe you have a tricks for this.

Thanks in advance,

Micka.

Hello @neosaiyan,
Welcome!
I’m not sure. I’ve asked the Telegraf team. Thanks for your patience.

Hello Anais,
Thx for your reply.
For My second question i just see that is id of telegraf container(not host server). But if i could display a « name » instead of id it will be perfect.
Micka

@neosaiyan Sorry to hear you are having problems.

1st question re hostname: if you connect to the VM can you look up the hostname there? If not, then this is probably something related to your DNS settings

2nd question: telegraf will use whatever comes from hostname on a system, if it is reporting IPs then this is probably confirming that DNS in docker or between your containers is not quite setup

1 Like

Hello Mya
Thx for your reply.
I will check that in Back of My holidays.
But My dns are clean
Micka

Hello Mya,

Maybe I expressed myself badly. When I browse in influxdb or grafana the data from telegraf,
the host display the telegraf container ID. Can I change this with explicit labels ? for better reading.

Thx in advance.
Micka

The rename processor would work great for this!

Thx Mya,

I try to uncomment the processor rename lines but same problem.
do you have more documentation or examples for rename.processor please ?

Micka

@neosaiyan,

How do you want to set the hostname? Do you have an explicit name you want to set it?

Hi @jpowers

Just want to display hostname instead of telegraf container ID.
for example my hostname server is : CIBLE01.
I want to display CIBLE01 instead of the container ID

dunno if i am clear…

Micka

As part of the agent configuration a user can set the hostname to a value of their choosing, otherwise os.Hostname() or similar is used to determine the system or in this case, container hostname.

@jpowers , here is my telegraf.conf
image
I change nothing then os.hostname() should be used for dest host.
but same result
image

Micka

for completed, when i launch a docker-stack deploy:
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z W! DeprecationWarning: Option “perdevice” of plugin “inputs.docker” deprecated since version 1.18.0 and will be removed in 2.0.0: use ‘perdevice_include’ instead
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! Starting Telegraf 1.23.4
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! Loaded inputs: cpu disk diskio docker kernel mem net processes swap system
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! Loaded aggregators:
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! Loaded processors: rename
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! Loaded outputs: influxdb_v2
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! Tags enabled: host=e92281e9e7d8
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z W! Deprecated inputs: 0 and 2 options
telegraf_telegraf.0.r1gatde3cmli@CIBLE05 | 2022-09-02T13:15:12Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:“e92281e9e7d8”, Flush Interval:10s

in fact it seems to be normal. it takes the hostname of the container. But I want the hostname of the server host.
Micka

Ok i found the solution on another topic

you must put this on the docker-compose
telegraf:
image: telegraf:1.21 # not the latest
hostname: “{{.Node.Hostname}}”

Thanks for the helping