Hi,
I am running the telegraf agent on Ubuntu server.
Initially, I was only monitoring the local server stats every 30 seconds, so had one config file located at /etc/telegraf/telegraf.conf
and it was working fine.
I then tried to also do some HTTP monitoring from the same server (every 6 hours), so created another config file at:
/etc/telegraf/telegraf.d/httpmonitor.conf
It’s working fine.
Now, the agent seems to only report on HTTP monitoring data but no server stats anymore.
How can I get both configuration files to run for the same agent? Or do I need to run two Telegraf agents?
Thanks!
You can include multiple input plugins in your telegraf config.
Please see this also:
opened 01:12AM - 30 Aug 19 UTC
closed 06:53PM - 30 Aug 19 UTC
discussion
area/configuration
Hi There,
I run Telegraf docker (v1.11.5- Awesome utility by the way!) and or… iginally had one big /etc/telegraf/telegraf.conf file with a single (InfluxDB) output and a few different input plugins (each sometimes with multiple agents) - Something like this structure of /etc/telegraf/telegraf.conf:
**/etc/telegraf/telegraf.conf:**
```
[Output Plugin - InfluxDB]
[Input Plugin - local metrics]
[Input Plugin - SNMP] - Agent IP1, Agent IP2, ..., Agent IPx
[Input Plugin - Docker] - Agent IP1
[Input Plugin - Docker] - Agent IP2
...
```
Now, since I understand that the above single config file causes Telegraf to run the file in series, I was seeing an issue where if Agent IPx was down this could cause the SNMP Input Plugin to timeout before it was able to contact/return results from Agent IPy. So I decided to break the config up into multiple .conf files as follows, all under `/etc/telegraf/telegraf.d/ ` and **this time with no main** `/etc/telegraf/telegraf.conf` file:
**/etc/telegraf/telegraf.d/telegraf-input-metrics.conf:**
```
[Output Plugin - InfluxDB]
[Input Plugin - local metrics]
```
**/etc/telegraf/telegraf.d/telegraf-snmp-AgentIP1.conf:**
```
[Output Plugin - InfluxDB]
[Input Plugin - SNMP] - Agent IP1
```
...
**/etc/telegraf/telegraf.d/telegraf-snmp-AgentIPX.conf:**
```
[Output Plugin - InfluxDB]
[Input Plugin - SNMP] - Agent IPx
```
**/etc/telegraf/telegraf.d/telegraf-docker-AgentIP1.conf:**
```
[Output Plugin - InfluxDB]
[Input Plugin - Docker] - Agent IP1
```
**/etc/telegraf/telegraf.d/telegraf-docker-AgentIP2.conf:**
```
[Output Plugin - InfluxDB]
[Input Plugin - Docker] - Agent IP2
```
In doing this, I have a few questions:
(1) With Telegraf command configured to run as `telegraf --config-directory /etc/telegraf/telegraf.d` in the container, and with **main** `/etc/telegraf/telegraf.conf` file _(all split conf files under /etc/telegraf/telegraf.d/)_: I got the following error on starting the container - I assume this means that there **must** be a `/etc/telegraf/telegraf.conf` file, even if the `--config-directory /etc/telegraf/telegraf.d` switch is passed to the telegraf command in the container?
```
2019-08-30T01:01:52Z I! Starting Telegraf 1.11.5
2019-08-30T01:01:52Z E! [telegraf] Error running agent: No config file specified, and could not find one in $TELEGRAF_CONFIG_PATH, /root/.telegraf/telegraf.conf, or /etc/telegraf/telegraf.conf
```
(2) To work around the above, I moved one of the config files (/etc/telegraf/telegraf.d/telegraf-input-metrics.conf) to /etc/telegraf/telegraf.conf and was then able to start the application with the following output to the log:
```
2019-08-30T01:04:48Z I! Starting Telegraf 1.11.5
2019-08-30T01:04:48Z I! Using config file: /etc/telegraf/telegraf.conf
2019-08-30T01:04:49Z I! Loaded inputs: disk diskio kernel mem processes swap system cpu docker docker file file snmp snmp snmp snmp snmp snmp snmp snmp snmp snmp
2019-08-30T01:04:49Z I! Loaded aggregators:
2019-08-30T01:04:49Z I! Loaded processors:
2019-08-30T01:04:49Z I! Loaded outputs: influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb influxdb
```
I assume that the many "influxdb" outputs that are shown (last line above) are because each of my config files has the [Output Plugin - Influx DB] header therefore, is the recommended approach to:
Configure /etc/telegraf/telegraf.conf as **just** the main [Output Plugin - InfluxDB] and configure all the .conf files under /etc/telegraf/telegraf.d/ to just be [Input Plugin - X]?
**If so,** I assume this means that all the .conf files under /etc/telegraf/telegraf.d inherit the [Output Plugin - InfluxDB] from the main /etc/telegraf/telegraf.conf file so they know where to write the output to?
**OR** do I really still need to declare the [Output Plugin - InfluxDB] header at the top of each config file under /etc/telegraf/telegraf.d/?
Thank you!
1 Like
Thank you. I think I had already seen this.
However, in my case, I would like:
1 - Monitoring 1 to check server stats every 30 seconds
2- Monitoring 2 to check a specific HTTP address every 6 hours
Since the two schedules are not aligned, I assume I have to run two agents, because one agent can only have one schedule?
That’s not the case, interval
can be overridden in any input plugin
interval : Overrides the interval
setting of the agent for the plugin. How often to gather this metric. Normal plugins use a single global interval, but if one particular input should be run less or more often, you can configure that here.
you can freely set whatever interval you want per input plugin