Data not showing up in Influxdb - Telegraf tags

telegraf

#1

I set up tags in my Telegraf config in order to route the input to the right output. Config looks like:

[[outputs.influxdb]]
   tagexclude = ["influxdb_database"]
   [outputs.influxdb.tagpass]
      influxdb_database = ["e2e_service_mon"]

[[outputs.influxdb]]
     [outputs.influxdb.tagdrop]
        influxdb_database = ["*"]

[[inputs.ping]]
    urls = ["amazon.com"]
    [inputs.ping.tags]
        tag1 = "dummy1"
        tag2 = "dummy2"                
        influxdb_database = "e2e_service_mon"

[[inputs.cpu]] 
    ## Whether to report per-cpu stats or not
    percpu = true     
    ## Whether to report total system cpu stats or not
    totalcpu = true                   
    ## If true, collect raw CPU time metrics.  
    collect_cpu_time = false
   ## If true, compute and report the sum of all non-idle CPU states.
   report_active = false

Telegraf log shows:
2019-03-04T06:45:40Z E! Error writing to output [influxdb]: could not write any address
2019-03-04T06:45:40Z D! Output [influxdb] buffer fullness: 379 / 10000 metrics.
2019-03-04T06:45:40Z E! [outputs.influxdb] when writing to [http://localhost:8086]: Post
http://localhost:8086/write?db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
2019-03-04T06:45:40Z E! Error writing to output [influxdb]: could not write any address
2019-03-04T06:45:50Z D! Output [influxdb] buffer fullness: 379 / 10000 metrics.
2019-03-04T06:45:50Z D! Output [influxdb] buffer fullness: 120 / 10000 metrics.
2019-03-04T06:45:50Z E! [outputs.influxdb] when writing to [http://localhost:8086]: Post
http://localhost:8086/write?db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
2019-03-04T06:45:50Z E! Error writing to output [influxdb]: could not write any address
2019-03-04T06:45:50Z E! [outputs.influxdb] when writing to [http://localhost:8086]: Post
http://localhost:8086/write?db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
2019-03-04T06:45:50Z E! Error writing to output [influxdb]: could not write any address

Note, that the tcp influxdb output is not even existing in the confi file, no idea why it pops up like this in the log.

The issue is, that I don’t get any data in Influxdb, not in the servermetrics db nor in the e2e_service_mon from this host, other hosts without the routing tags are working.


#2

Hi , I think that is because the urls part is misssing in the [[outputs.influxdb]] section ?
The tcp Influxdb output is the default that is why you see it in the logs …
Hope this helps , have a good workweek :slight_smile:


#3

Hi

I just didn’t copy the whole config, but it exists.


#4

Strange , if your config is correct then maybe Telegraf was not restarted after modifying the configfile?


#5

Or … you have no input that tags the metrics ?

Routing metrics to different outputs based on the input. Metrics are tagged with influxdb_database in the input, which is then used to select the output. The tag is removed in the outputs before writing.

[[outputs.influxdb]]
urls = [“http://influxdb.example.com”]
database = “db_default”
[outputs.influxdb.tagdrop]
influxdb_database = ["*"]

[[outputs.influxdb]]
urls = [“http://influxdb.example.com”]
database = “db_other”
tagexclude = [“influxdb_database”]
[outputs.influxdb.tagpass]
influxdb_database = [“other”]

[[inputs.disk]]
[inputs.disk.tags]
influxdb_database = “other”

Click here and go to the end of the document


#6

I have:

[[inputs.ping]]
    urls = ["amazon.com"]
    [inputs.ping.tags]
        tag1 = "dummy1"
        tag2 = "dummy2"                
        influxdb_database = "e2e_service_mon"

#7

I will try to get it working om my test server …


#8

It am convinced it must have something to do with your url settings …

I have tried wit a telegraf.config like this and that works ,
a database dbcpu was automatically created and the measurement cpu …

I can only reproduce your error if I stop my influx database or if i change my port in my url config in telegraf to a wrong port…

[agent]
logfile = “/var/log/telegraf/telegraf.log”
interval = “1s”

[[outputs.influxdb]]
urls = [“http://127.0.0.1:8086”]
database = “dbcpu”
tagexclude = [“influxdb_database”]
[outputs.influxdb.tagpass]
influxdb_database = [“dbcpu”]

[[outputs.influxdb]]
urls = [“http://127.0.0.1:8086”]
database = “dbdisk”
[outputs.influxdb.tagdrop]
influxdb_database = ["*"]

[[inputs.cpu]]
[inputs.cpu.tags]
tag1= “dummy”
influxdb_database = “dbcpu”

[[inputs.disk]]
[inputs.disk.tags]
tag1 = “dummy”
influxdb_database = “dbdisk”


#9

The url config is:
urls = ["https://prodinfluxwwlab.sharedtcs.net:443"]

And it works on a conf file which doesn’t have the tags.

In your example, the inputs.cpu is put into dbcpu and inputs.disk into dbdisk?


#10

in my example the inputs.cpu is put into dbcpu and
inputs.disk is ignored

but if I comment two lines in my config the inputs.disk goes to dbdisk

[[outputs.influxdb]]
     urls = ["http://127.0.0.1:8086"]
     database = "dbdisk"
#     [outputs.influxdb.tagdrop]
#        influxdb_database = ["*"]

#11

my influx database is on localhost port 8086

> settings
Setting           Value
--------          --------
Host              localhost:8086
Username
Database
RetentionPolicy
Pretty            false
Format            column
Write Consistency all
Chunked           true
Chunk Size        0

#12

if I change my config as follows , the inputs.disks goes to dbdisk as well , so maybe the
influxdb_database = ["*"] is the reason it doesn’t work ?

[[outputs.influxdb]]
   urls = ["http://127.0.0.1:8086"]
   database = "dbdisk"
   [outputs.influxdb.tagdrop]
      influxdb_database = ["dbcpu"]

can you share the following from your telegraf logfile ?

2019-03-04T12:44:25Z I! Loaded inputs: inputs.cpu inputs.disk
2019-03-04T12:44:25Z I! Loaded outputs: influxdb influxdb influxdb

ps : I could reproduce the problem if I place the following not as the last part in the
[[outputs.influxdb]] section …

[outputs.influxdb.tagpass]
influxdb_database = [“dbcpu”]

can you share the complete [[outputs.influxdb]] sections ?


#13

That’s the resolution. Thanks!


#14

Great ! Can you mark this as solved please :slight_smile: