3

I am trying to integrate New Relic with Spring Boot actuator. Most of the tutorials and response in StackOverflow itself suggest to use New Relic Java Agent but as per Spring Boot documentation installing Java Agent is not mandatory (unless I misunderstood something) also checked this. So, here is my application.properties currently.

management.metrics.export.newrelic.enabled = true
management.metrics.export.newrelic.api-key = <API_KEY>
management.metrics.export.newrelic.account-id = <ACCOUNT_ID>
logging.level.io.micrometer.newrelic=TRACE
management.metrics.export.newrelic.step=30s

and in the log I am seeing

2021-01-11 12:05:18.315 DEBUG 44635 --- [trics-publisher] i.m.n.NewRelicInsightsApiClientProvider  : successfully sent 73 metrics to New Relic.

Based on this logs it looks like it is sending logs. But I have no idea where to see this logs. Ideally I would like to pass app name as well so that I can differentiate metric by app name and preferably by env as well later. Any suggestions?

nicholasnet
  • 2,117
  • 2
  • 24
  • 46

1 Answers1

1

To add "app name" and "env" to your metrics, you just need to configure the MeterFilter with the common tags:

@Configuration
public class MetricsConfig {

    @Bean
    public MeterFilter commonTagsMeterFilter(@Value("...") appName, @Value("...") env) {
        return MeterFilter.commonTags(Tag.of("app name", appName), Tag.of("env", env);
    }
}

Setting the following property you should be able to see what metrics are being sent to NewRelic:

logging.level.io.micrometer.newrelic=TRACE
Ilya Zinkovich
  • 4,082
  • 4
  • 25
  • 43
  • I already have `logging.level.io.micrometer.newrelic=TRACE` but all I am getting is that log message for some reason. – nicholasnet Jan 11 '21 at 22:44
  • @nicholasnet, with the updated tags can you see the metrics at least on NewRelic? – Ilya Zinkovich Jan 12 '21 at 00:24
  • No... that’s one of the problem I am not sure where to look at. I mean do I need to create app in NewRelic first or query in Insight. That’s where I am stuck. Thank you very much for that tag suggestion by the way. – nicholasnet Jan 12 '21 at 00:41
  • @nicholasnet, when I worked with NewRelic I used a java agent and only saw the same log message as you. In fact, micrometer will reveal what it planned to send to NewRelic only in case of the error: https://github.com/micrometer-metrics/micrometer/blob/ff730eb50f048d66d47609061448cb2ce357a55f/implementations/micrometer-registry-new-relic/src/main/java/io/micrometer/newrelic/NewRelicInsightsApiClientProvider.java#L270 – Ilya Zinkovich Jan 12 '21 at 12:23
  • @nicholasnet, use Data Explorer in NewRelic Insights to check if NewRelic receives any of your metrics or not. https://docs.newrelic.com/docs/insights/use-insights-ui/explore-data/event-explorer-query-chart-your-event-data – Ilya Zinkovich Jan 12 '21 at 12:26
  • No I do not see anything in New Relic side. – nicholasnet Jan 12 '21 at 15:05
  • @nicholasnet, then put a breakpoint in the `NewRelicInsightsApiClientProvider` `sendEvents` method and check where your metrics are sent. Check all the values there: insightsEndpoint, config.apiKey(), events, including what a response from NewRelic looks like. – Ilya Zinkovich Jan 12 '21 at 16:17
  • It is going to `https://insights-collector.newrelic.com/v1/accounts//events`. I even fired cURL request with dummy data and I am getting 200 response. `{"success":true, "uuid":"6e0cdaa1-001f-b000-0000-0176f7d40c59"}` but I see nothing in NewRelic side. – nicholasnet Jan 12 '21 at 18:25
  • @nicholasnet, then check if your data is correctly parsed by NewRelic. https://discuss.newrelic.com/t/finding-data-from-an-event-api-call/84607/5 – Ilya Zinkovich Jan 12 '21 at 19:06
  • 2
    Thank you. That link helped me a lot. I must say, NewRelic documentation is wrong as it states that you can see an entity in list once it gets sent to NewRelic however that was not the case for me. As it turns out Spring Boot Actuator by default sends the event as SpringBootSample hence you need to use NRQL like this SELECT * FROM SpringBootSample SINCE last week in InSight. Now, I still need to figure out how to make Dashboard out of these data using NRQL which will be my next step. But thank you very much for your help. I really appreciate it. – nicholasnet Jan 13 '21 at 04:22
  • Do we need to run a new relic server in our local system? Like we do for Prometheus. I ran Prometheus in a Docker container and it was able to scrape data from my application and display it in the dashboard. I want to do the same using new relic. For this after all the configuration do we need new relic to run locally? – Arpan Banerjee Oct 24 '21 at 05:02
  • I did the same config as mentioned in the question, I can also see the Debug logs saying metrics has been sent to new relic. What is the next step? What do I need to do to see the data in new relic's dashboard like we see for prometheus? Please help someone, I did not find any clear instructions anywhere. – Arpan Banerjee Oct 24 '21 at 05:06