I have my main telegraf.conf file in /etc/telegraf/ which contains the Influx database name and password and all my telegraf configuration files (about 30) are in /etc/telegraf/telegraf.d.
They just run SNMP queries again remote devices and puts the results my single influx database, it’s great and then into Grafana.
Most just start off with this:
[[inputs.snmp]]
agents = [ "10.1.1.1:161" ]
version = 2
community = "password123"
[inputs.snmp.tags]
locationd = "NY"
[[inputs.snmp.field]]
name = "hostname"
oid = "1.3.6.1.2.1.1.5.0"
[[inputs.snmp.field]]
name = "uptime"
oid = "1.3.6.1.2.1.25.1.1.0"
[[inputs.snmp.field]]
name = "cpu1"
oid = "1.3.6.1.2.1.25.3.3.1.2.1"
Now I have created a new influx database and a new telegraf.conf file in /etc/telegraf/telegraf.d. and want to send the data to this new database, but it won’t. Instead this new database gets all the new data from the other telegraf files. So I’m getting the same data in both databases now. It seems the telegraf files I have in /etc/telegraf/telegraf.d/ populate both databases now even though I’ve not told them to.
My new telegraf file that I wanted to do to this new database is configured like this:
[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "newdb"
skip_database_creation = true
username = "user123"
password = "passwoord"
[[inputs.snmp]]
agents = [ "10.2.2.2.2:161" ]
version = 2
community = "password"
[inputs.snmp.tags]
location = "NY"
[[inputs.snmp.field]]
name = "temp"
oid = "1.3.6.1.4.1.48690.5.3"
I’ve looked at mine https://pastebin.com/hDbQwppy and the above link and can’t seem to understand how mine should look like, I’m not sure if you can give me an example to work on to help me on my way, I’d be so thankful.
There are indeed 2 options, use metric filtering as in my docs I linked earlier or put the name of the bucket in a tag. Both options require a tag to be set on the input to be able to differentiate. I still don’t know how you want to differentiate both inputs. (Hint based on the config file is not possible as they all get merged at startup)
Hey @Hipska thanks for stinking with me on this, as I know know from what you said all the config files all merge at startup so I need to somehow tag this new config to point to another database and struggling to write a config for this.
My of my configs in telegraf.d (main 1 in telegraf) so I created this new config that I wanted to point to a new database, all my configs include:
telegraf-1.conf
[[inputs.snmp]]
agents = [ "1.1.1.4:161" ]
version = 2
community = "mypassword"
[inputs.snmp.tags]
location = "New York"
[[inputs.snmp.field]]
name = "lightsensor"
oid = "1.3.6.1.4.1.48690.5.3"
telegraf-2.conf
[[inputs.snmp]]
agents = [ "1.1.2.4:161" ]
version = 2
community = "mypassword"
[inputs.snmp.tags]
location = "Paris"
[[inputs.snmp.field]]
name = "lightsensor"
oid = "1.3.6.1.4.1.48690.5.3"
telegraf-3.conf
[[inputs.snmp]]
agents = [ "1.1.3.4:161" ]
version = 2
community = "mypassword"
[inputs.snmp.tags]
location = "London"
[[inputs.snmp.field]]
name = "lightsensor"
oid = "1.3.6.1.4.1.48690.5.3"
So in this example config 1 and 2 will use the default telegraf.conf file and merge with it and use the database configure int there. Config 3 is what I want to go into a new database.
On config 3 is it possible to add a tag to it called “custom123” which the other configs don’t have and be used as the differentiation and then send to the new database? Then any new configs I add I can use that tag to send to this new database and not get merged with the other configs and into the default database?
[[inputs.snmp]]
alias = "device-3" # useful for debugging (the logs will show errors came from this config)
agents = [ "1.1.3.4:161" ]
version = 2
community = "mypassword"
[inputs.snmp.tags]
location = "London"
influxdb_database = "custom123" # here you specify if this needs to go to another DB
[[inputs.snmp.field]]
name = "lightsensor"
oid = "1.3.6.1.4.1.48690.5.3"
So I was wondering where I put the password for the new database, this is my reconfigured config, how does it look? I’ve set the DB output at the top and tagged it to use this database and not the main default one, am I missing anything?
Like this Hipska? As you can see Im trying not to use the current default database called “defaultdatabase” but use “newdatabase” instead. Also where to I tell the config file to use the “newdatabase” password I configured?
[[outputs.influxdb]]
urls = [“http://1.2.3.4:8086”] #database I don’t wnat to use
database = “defaultdatabase”
[outputs.influxdb.tagdrop]
influxdb_database = [“*”]
[[outputs.influxdb]]
urls = [“http://1.2.3.4:8086”] #database I want too use
database = “newdatabase” #database I don’t wont to use
tagexclude = [“defaultdatabase”]
[outputs.influxdb.tagpass]
influxdb_database = [“newdatabase”]
[[inputs.snmp.field]]
name = “lightsensor”
oid = “1.3.6.1.4.1.48690.5.3”
[inputs.disk.tags]
influxdb_database = “newdatabase”