Skip to content

Sanitize 'win_perf_counters' Counter names for Graphite #1117

@G-regL

Description

@G-regL

When sending Telegraf data to Graphite, many of the metrics generated by the win_perf_counters input plugin aren't properly sanitized, and get ignored by Carbon.

For example, for the following config, only Processes and Threads succeed:

[[outputs.graphite]]
  template = "host.measurement.tags.field"

[[inputs.win_perf_counters]]
  [[inputs.win_perf_counters.object]]
    ObjectName = "System"
    Counters = ["Context Switches/sec", "System Calls/sec", "Threads", "System Up Time", "Processes", "Processor Queue Length"]
    Instances = ["------"]
    Measurement = "win_system"

If run in debug mode, telegraf produces this output:

> win_system,host=ServerA,objectname=System Context\ Switches/sec=9189.787 1461855980003819600
> win_system,host=ServerA,objectname=System System\ Calls/sec=41990.85 1461855980003819600
> win_system,host=ServerA,objectname=System Threads=2260 1461855980013820100
> win_system,host=ServerA,objectname=System System\ Up\ Time=1480454.9 1461855980013820100
> win_system,host=ServerA,objectname=System Processes=158 1461855980013820100
> win_system,host=ServerA,objectname=System Processor\ Queue\ Length=0 1461855980023820600

The metrics are received by carbon, but it throws these 4 errors:

28/04/2016 11:06:20 :: invalid line (ServerA.win_system.System.Context Switches/sec 9189.787 1461855980) received from client 127.0.0.1:57807, ignoring
28/04/2016 11:06:20 :: invalid line (ServerA.win_system.System.System Calls/sec 41990.85 1461855980) received from client 127.0.0.1:57807, ignoring
28/04/2016 11:06:20 :: invalid line (ServerA.win_system.System.System Up Time 1.4804549e+06 1461855980) received from client 127.0.0.1:57807, ignoring
28/04/2016 11:06:20 :: invalid line (ServerA.win_system.System.Processor Queue Length 0 1461855980) received from client 127.0.0.1:57807, ignoring

I see that the Graphite output serializer sanitizes the bucket name, but it doesn't sanitize the field itself, and win_perf_counters doesn't do any kind of sanitizing when gathering metrics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions