statsd_input: Fix config to take host instead of hosts - #6592
Conversation
|
With a single host also, the default remains the same. |
|
@ishleenk17 I think it's working in standalone because I am running the Node JS client from the same machine. Hence there are no issues in collecting the metrics. But when it is running in some other container and if I give the host of my agent in the client script, it does not recognize my host. By the way, I am able to run the system tests with this change. |
No. Change would not reflect for |
There was a problem hiding this comment.
We should add a system test that starts the input and streams in a few StatsD events over UDP. Assuming the protocol is simply text based then you could follow the same setup as the udp package. Like drop data like this into a file and have elastic/stream send it
python.counter:1|cpython.gauge.foo:10|gpython.average.avg:5|apython.timer.total:0.07200241|mspython.counter:1|cpython.gauge.foo:10|gpython.average.avg:5|apython.timer.total:0.29730797|mspython.counter:1|cpython.gauge.foo:10|gpython.average.avg:5|apython.timer.total:0.30040741|mspython.counter:1|cpython.gauge.foo:10|gpython.average.avg:5|apython.timer.total:0.29134750|ms
This would verify that the input is using 0.0.0.0 as the bind address because the test is performed between containers. And it would be mandatory for 0.0.0.0 to be working property for this test to pass.
| required: true | ||
| show_user: true | ||
| default: | ||
| - http://127.0.0.1 |
There was a problem hiding this comment.
We usually like to have the user opt-in to having the Agent listen on all interfaces for security reasons. I don't know that there is precedence for using 0.0.0.0 as the default. The UDP input would be a good example to follow. IIRC the description explains when to change to the wildcard address.
There was a problem hiding this comment.
Agreed. I kept it 0.0.0.0 so that by default it listens on all interfaces but yes if we are usually keeping it as an opt-in then it makes sense. I'll make similar changes here. Thanks for pointing that out!
There was a problem hiding this comment.
Did some more changes based on udp package:
- s/host/listen_address
- s/port/listen_port
and so on.
Because it makes more sense. What do you think?
💚 Build Succeeded
History
cc @shmsr |
So, @aliabbas-elastic is adding some system tests as part of this PR (waiting for this PR to be merged). Should I work with him to add the required tests you suggested in that PR itself? Thanks for suggesting cc: @aliabbas-elastic (you can remove the node.js script that you are using as a statsd client and instead use elastic/stream) |
| - http://127.0.0.1 | ||
| - name: port | ||
| default: localhost | ||
| - name: listen_port |
There was a problem hiding this comment.
Since we are using the statsd/server input, let's keep it in sync with that.
If we think this change is required we should change in the beats code as well.
There was a problem hiding this comment.
IMO, we should go with listen_{address,port} because:
- In
packages/statsd_input/agent/input/input.yml.hbs, the mappings are done correctly so that it works well with the beats code. I tested the current changes and they are working fine. - Changes in the beats code involve the following breakage:
- statsd uses a common udp package used by even other modules in metricbeat.
- Changes in the configuration will impact all modules which is even fine but if any users upgrade the module they are using then their older configuration would break as we'd moving from
host->listen_address.
- Also, I think we should go with this because it conveys the message better:
listen_addresscompared tohostmakes it clear that statsd package is listening on an address whereashostis not implying that clear aslisten_address. This sets the expectation clear even if some newbie is starting with integrations and statsd.
What do you think? I even asked the same here.
|
Package statsd_input - 0.2.1 containing this change is available at https://epr.elastic.co/search?package=statsd_input |
What does this PR do?
While debugging why the client is not able to send data to the statsd_input's spawned server, I found that the configuration used is incorrect making the server listen on a default IP which is not always correct unless someone uses the standalone elastic-agent. Also, accepting multiple hosts for a server doesn't make sense and that's why also only one host is considered in metricbeat module side of beats. Also, the IP shouldn't have
http://prefix and it should be without it.Found this when trying to send data using a statsd client from a different container which is part of the same network as of elastic-agent's container. Also made a toy UDP server to check if it receiving the packets in the same container but metricbeat was not receiving them. When checking with tcpdump, I noticed that UDP packets are reaching the correct destination but the server always running on localhost where the packet is destined for another IP and that is the reason for metricbeat module not receiving the packets. But if we run the client on the same container as elastic-agent then it's possible to send it to its localhost directly and it is even true locally and that's why it was working there before.
Ref:
metricbeat's statsd module is dependent on the UDP helper package and from this we can see that it accepts
hostandhosts.Update:
Checklist
changelog.ymlfile.How to test this PR locally