Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Pipes should be escaped or replaced before sending to datadog #6

Open
hurricane766 opened this issue Sep 17, 2015 · 2 comments
Open

Comments

@hurricane766
Copy link

Hi,

This is how I'm using connect-datadog in my app:
var connectDatadog = require('connect-datadog');
app.use(connectDatadog({response_code: true, path: true, method: true}));

I've noticed that my syslogs are filling up with errors like this:

ERROR (dogstatsd.py:309): Error receiving datagram#012Traceback (most recent call last):#12 File "/opt/datadog-agent/agent/dogstatsd.py", line 297, in start#012 aggregator_submit(message)#12 File "/opt/datadog-agent/agent/aggregator.py", line 606, in submit_packets#012 parsed_packets = self.parse_metric_packet(packet)#12 File "/opt/datadog-agent/agent/aggregator.py", line 481, in parse_metric_packet#012 raise Exception('Metric value must be a number: %s, %s' % (name, raw_value))#012Exception: Metric value must be a number: node.express.router.response_code.all, url(api

I've got some javascript files missing obviously, but I didn't think this should be causing syslog errors. I wrote some more information out of /opt/datadog-agent/agent/aggregator.py and here is the packet that is being passed through to be parsed, as well as the associated error:

Packet:node.express.router.response_code.404:1|c|#route:/:url(api|components|app|bower_components|assets)/*,method:get,path:/app/shims/combos/1.js,response_code:404

Error: Metric value must be a number: node.express.router.response_code.404, url(api

aggregator.py does state that the schema of a dogstatsd packet is expected like this:
<name>:<value>|<metric_type>|@<sample_rate>|#<tag1_name>:<tag1_value>,<tag2_name>:<tag2_value>:<value>|<metric_type>...

For some reason it looks like the parser is seeing url(api as the value for node.express.router.response_code.404.

I'm not sure where the actual error is, but the parser is choking on these types of packets.

Thanks

@hurricane766
Copy link
Author

Update from datadog support:

| is used by the statsd protocol to delimit the fields. When used in a tag, it
needs to be escaped or it'll break Dogstatsd parsing packet method 
and leads to some weird side effect errors.

The node-dogstatsd package needs to escape the | character (which is not
officially supported by Datadog), i.e. to replace it with something else.

@hurricane766
Copy link
Author

I have verified that the problem is you can use pipes when defining express.js routes, and then node-connect-datadog is sending them to datadog. But datadog uses pipes to delimit fields.

For example

//This will match paths starting with `/ab` and `/ac`:
app.use('/a(b|c)', function (req, res, next) {
  next();
});

@hurricane766 hurricane766 changed the title datadog-agent syslog errors parsing 404s Pipes should be escaped or replaced before sending to datadog Nov 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant