1

I started elastic apm agent and trying to push custom logs into elastic but those logs are not available into the elastic. Can you guys please let me know how to achieve custom logs. Below I attached my code snippet.

const apm = elasticApm.start({
        "serviceName": "",
        "secretToken": "xxxx",
        "serverUrl": "xxxx",
        "environment": "xxx"
      });
apm.setCustomContext({"apm": "test"}); // This is custom context is missing in elastic side. 
apm.captureError(new Error('dummy error')); // I can able to see this error in elastic.
  • Did you find a solution? I think the node.js is bugged... – Rubén Vega Feb 24 '22 at 09:58
  • @RubénVega Where are you looking exactly? – Val Feb 25 '22 at 07:45
  • I just want that the setCustomContext() function work, and traces what I need. – Rubén Vega Feb 25 '22 at 10:54
  • @RubénVega yes, but what makes you think that it doesn't work? Where are you looking and you don't find the information? – Val Feb 28 '22 at 06:49
  • I've look up in the documents inserted into ES from the discover and also on from the trasactions. The fields inserted with setCustomContext() are not shown but the ones added with addLabels() or capture Error() are. – Rubén Vega Feb 28 '22 at 10:40
  • You are aware, though, that the custom context data [is not indexed](https://www.elastic.co/guide/en/apm/guide/8.0/metadata.html#custom-fields) and thus cannot be searched, right? – Val Feb 28 '22 at 14:17
  • Yes, but still, they should be visible under transaction.custom, but they are not :( – Rubén Vega Feb 28 '22 at 14:46
  • @RubénVega could this be a potential reason: https://github.com/elastic/apm-agent-nodejs/issues/515#issuecomment-413126577 ? – Val Mar 01 '22 at 07:14
  • I don't think so... I have call `apm.currentTransaction` before `apm.setCustomContext()` and it returns the transaction. BTW IDK how, but the custom fields are included now... I didn't do anything... What could have happened? – Rubén Vega Mar 01 '22 at 09:21
  • @RubénVega It's called karma :-) Just kidding, but hard to know what happened without knowing more about your environment and how it works. But glad it's working agai :-) – Val Mar 02 '22 at 06:42
  • I just mounted a test in my local environment, an ES, kibana and apm server each in its docker container, everithing is by default except the conecctions. Then I just run also a test node.js app, with some httprequest and the agent to try what is captured and what it's not... – Rubén Vega Mar 02 '22 at 10:43

0 Answers0