grobian/carbon-c-relay

Do not prefix stats

ssko1 opened this issue · 8 comments

ssko1 commented

Is there a way to disable prefixing with the statistics construct?

When I created my own statistics construct, I expected it to override the default configuration provided by carbon-c-relay.

# my relay.conf
statistics
    submit every 10 seconds
    send to forwarder
    stop
    ;

But I end up with the configuration on boot

# printed configuration on startup
statistics
    submit every 10 seconds
    prefix with carbon.relays.myhostname
    send to forwarder
    stop
    ;

Hey, not sure if this works, but have you tried prefix with ""?

ssko1 commented

I did try! Quotes result in an error

[2022-10-12 18:55:29] relay.conf:13:17: empty string
[2022-10-12 18:55:29]     prefix with ""

ok, there's two ways I can think of:

statistics prefix with .;

or a bit more convoluted

statistics prefix with somethingrandom; rewrite ^somethingrandom\.(.*) into \1;

But I hope the first works for you, because then you can use the "send to".

ssko1 commented

Is there any insight as to why . would work? A simple test shows the following internal stats

.dispatcher1.metricsReceived 0 1665602450
.dispatcher1.metricsBlackholed 0 1665602450
.dispatcher1.metricsDiscarded 0 1665602450
.dispatcher1.wallTime_us 7 1665602450

I'm leaning a bit more into the rewrite option, but haven't tested it out yet

I had hoped that the metrics would be sanitised, hence the .. I think with current code, you can't do it other than with a rewrite rule. If that is too limited, I'll have to add some syntax to allow you to have no prefix.

ssko1 commented

I did some finagling and found that the following configuration

statistics
    # Every 10 seconds is required
    submit every 10 seconds
    prefix with foo
    ;

rewrite ^foo\.(.*) into \1;

match *
    send to forwarder
    stop
    ;

works. I don't see an issue with this approach, do you have any feedback? The "every 10 seconds" rule is important.

Nope, this should do it just fine.

ssko1 commented

Thanks for your help! I appreciate the feedback and quick response.