简体   繁体   English

如何在Azure Web作业中使用newrelic自定义指标?

[英]How to use newrelic custom metrics with azure web job?

I have a web job using c# that I would like to add some custom metrics like this 我有一个使用c#的网络作业,我想添加一些自定义指标

NewRelic.Api.Agent.NewRelic.IncrementCounter("IncrementCounter");

From what I can tell though I need the non IIS agent but I can't find any information on implementing this with a web job. 从我可以看出,虽然我需要非IIS代理,但是找不到有关通过Web作业实现此信息的任何信息。

Does anyone know of a way to set this up? 有人知道设置此方法的方法吗?

For starters, here is the article that explains things on how to get New Relic working with a Webjob. 对于初学者, 这里是解释如何使New Relic与Webjob一起工作的文章。

In summary ... 综上所述 ...

For code you have to install a nuget package: NewRelic.Agent.Api and write some new relic API calling code... eg log time taken for some custom event: 对于代码,您必须安装一个nuget包:NewRelic.Agent.Api并编写一些新的relic API调用代码...例如,一些自定义事件的日志时间:

public void LogTimeTaken(string taskType, string eventType, long duration)
{
    var metric = string.Format("Custom/{0}_{1}", taskType, eventType);
    NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric(metric, duration);
}

Configure the New Relic app settings in the App.config of the webjob: 在webjob的App.config中配置New Relic应用程序设置:

  <appSettings>
    <add key="NewRelic.AppName" value="[replace_with_the_name_you_want_reported_to_new_relic]" />
    <add key="NewRelic.AgentEnabled" value="true" />
    <add key="NewRelic.LicenseKey" value="[replace_with_your_key]" />
  </appSettings>

In the Kudu Portal for the Web App ... AKA SCM ... Add the "New Relic" Site Extension 在Web应用程序的Kudu门户中... AKA SCM ...添加“新文物”网站扩展

Once you have your webjob deployed and running you should be able to create a dashboard from your New Relic account (Tools menu, create custom dashboard). 部署并运行了Webjob之后,您应该能够从您的New Relic帐户创建一个仪表板(“工具”菜单,创建自定义仪表板)。 Use the metric: Custom/* to pick up all values ... choose calls per minute to get a count of the no of runs or average value to get the duration (assuming you used the code above) 使用度量标准:“自定义/ *”以选择所有值...选择每分钟通话次数以计算运行次数或平均值以获取持续时间(假设您使用了上面的代码)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM