Hi @stretch0. Thanks for the question.
Am I correct in thinking I should see these under APM -> Services -> Metrics
No. The APM > Services > $serviceName > Metrics
page only shows visualizations for a strict set of well-known metrics -- specifically some of the system.*
metrics described at Metrics | APM Node.js Agent Reference [4.x] | Elastic that are always collected by the Node.js APM agent. Eventually we hope to add visualizations for some of the nodejs.*
runtime metrics there.
There has been some discussion in the past for allowing user-defined metrics visualizations on this page, but I am not aware of current plans for that.
Do I need to add anything else to get the custom metrics to pull through?
Ultimately, the best way to visualize custom metrics is by building your own dashboard.
First, however, let's take an aside to look at the raw "metricset" documents that the Node.js APM agent should be sending to verify that your custom metric is getting through. In my example I used the following Node.js script. I used foo.connections
to have a different metric name:
// example-registerMetric.js
const apm = require('elastic-apm-node').start({
serviceName: 'example-registerMetric',
serverUrl: 'XXX',
secretToken: 'XXX',
metricsInterval: '5s',
apiRequestTime: '5s',
})
const socketClients = []
apm.registerMetric('foo.connections', () => socketClients.length);
// Randomly change the length of socketClients every 1s.
setInterval(function () {
if (Math.random() < 0.75) {
socketClients.push({type: 'socket', startTime: Date.now()})
} else {
socketClients.pop()
}
}, 1000)
I ran that for a while. Then I went to "Discover" in Kibana and searched for documents with that metric field using foo.connections: *
. That verifies that documents with my custom metric are getting into Elasticsearch.
Then I went to "Dashboard" in Kibana and created a dashboard with a visualization of "foo.connections". For example:
Please let me know if that doesn't answer your question.