newrelicnewrelic-platform

new Relic -how to pass custom Strings


I'd like to set a tag in new Relic and have it show up on the new relic dashboard. For example. I'd like to do something like this in psuedocode:

newRelic.setString("status","Disabled");

am i able to do this ?


Solution

  • Yes, you can collect so called custom parameters, metrics or use custom events.

    This is an example of a ruby code, but the following does apply for a Java lib also.

    class Cart
    
      def checkout()
        amount = compute_cart_total    # computes the amount to charge the customer
    
        ::NewRelic::Agent.record_metric('Custom/Cart/charge_amount', amount)
    
        charge_customer(amount)
        ...
      end
    end
    

    https://docs.newrelic.com/docs/apm/other-features/metrics/custom-metrics

    https://docs.newrelic.com/docs/apm/other-features/attributes/collecting-custom-attributes