Performance counter layout renderer parse bug
See original GitHub issueNlog version: 4.6.7
Platform: .Net 4.7
Current NLog config (xml or C#, if relevant)
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="c:/logs/nlog.log" internalLogLevel="Trace">
<variable name="facilityName" value="BppprCalc" />
<targets async="true">
<target name="graylogCounters" xsi:type="GraylogHttp" facility="${facilityName}" graylogServer="http://graylog" graylogPort="12201">
<parameter name="processor_total" layout="${performancecounter:Category=Processor:Counter=% Processor Time:Instance=_Total}" />
<parameter name="requests_per_second" layout="${performancecounter:Category=ASP.NET Apps v4.0.30319:Counter=Requests/Sec:Instance=${gdc:InstanceName}}" />
<parameter name="requests_in_queue" layout="${performancecounter:Category=ASP.NET Apps v4.0.30319:Counter=Requests in Application Queue:Instance=${gdc:InstanceName}}" />
<parameter name="errors_total_per_second" layout="${performancecounter:Category=ASP.NET Apps v4.0.30319:Counter=Errors Total/Sec:Instance=${gdc:InstanceName}}" />
</target>
</targets>
<rules>
<logger name="counters" level="debug" writeTo="graylogCounters" final="true"/>
</rules>
</nlog>
- What is the current result? Layout performance counter gives an error while parsing(I think) gdc:. I have putted variables in gdc and value is all right. This is internal logs of setup.
2019-08-30 13:19:16.5796 Warn Exception in layout renderer. Exception: System.InvalidOperationException: Экземпляр '${gdc' не существует в указанной категории.
в System.Diagnostics.CounterDefinitionSample.GetInstanceValue(String instanceName)
в System.Diagnostics.PerformanceCounter.NextSample()
в NLog.LayoutRenderers.PerformanceCounterLayoutRenderer.GetValue()
в NLog.LayoutRenderers.PerformanceCounterLayoutRenderer.Append(StringBuilder builder, LogEventInfo logEvent)
в NLog.LayoutRenderers.LayoutRenderer.RenderAppendBuilder(LogEventInfo logEvent, StringBuilder builder)
In english the result is the gdc do not exist in selected category.
- What is the expected result? performance counters layout renderer works well and can get data from gdc.
- I also tried to add a variable into target and reconfigure my config at application startup(global.asax).
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="c:/logs/nlog.log" internalLogLevel="Trace">
<variable name="facilityName" value="BppprCalc" />
<variable name="instanceName" value="DefaultInstance" />
<targets async="true">
<target name="graylogCounters" xsi:type="GraylogHttp" facility="${facilityName}" graylogServer="http://graylog" graylogPort="12201">
<parameter name="processor_total" layout="${performancecounter:Category=Processor:Counter=% Processor Time:Instance=_Total}" />
<parameter name="requests_per_second" layout="${performancecounter:Category=ASP.NET Apps v4.0.30319:Counter=Requests/Sec:Instance=${instanceName}}" />
<parameter name="requests_in_queue" layout="${performancecounter:Category=ASP.NET Apps v4.0.30319:Counter=Requests in Application Queue:Instance=${instanceName}}" />
<parameter name="errors_total_per_second" layout="${performancecounter:Category=ASP.NET Apps v4.0.30319:Counter=Errors Total/Sec:Instance=${instanceName}}" />
</target>
</targets>
<rules>
<logger name="counters" level="debug" writeTo="graylogCounters" final="true"/>
</rules>
</nlog>
code at startup
NLog.LogManager.Configuration.Variables["instanceName"] = "_LM_W3SVC_1_ROOT_BppprCalc";
NLog.LogManager.ReconfigExistingLoggers();
and there is another mistake
2019-08-30 14:04:12.7192 Warn Exception in layout renderer. Exception: System.InvalidOperationException: Экземпляр 'DefaultInstance' не существует в указанной категории.
в System.Diagnostics.CounterDefinitionSample.GetInstanceValue(String instanceName)
в System.Diagnostics.PerformanceCounter.NextSample()
в NLog.LayoutRenderers.PerformanceCounterLayoutRenderer.GetValue()
в NLog.LayoutRenderers.PerformanceCounterLayoutRenderer.Append(StringBuilder builder, LogEventInfo logEvent)
в NLog.LayoutRenderers.LayoutRenderer.RenderAppendBuilder(LogEventInfo logEvent, StringBuilder builder)
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Exeption parse error line - render tool
Hi! Multiple of my colleagues and me included experience problem with the render tool, I get the error "Render (130) Exception parse error...
Read more >Applied BES Template - performance counters not working
I have applied the solarwinds BES template, now all the "windows service monitor" are working. However all of the performance counters are not....
Read more >PerformanceCounter sometimes throws The Counter ...
Sometimes our code throws: "Error Message: The Counter layout for the Category specified is invalid, a counter of the type: AverageCount64, ...
Read more >Minimize main thread work - Chrome Developers
Learn about the browser's main thread and how you can optimize your web page to reduce main thread load and improve performance.
Read more >Using the Performance view
Use a profile build of your application to analyze performance. Frame rendering times aren't indicative of release performance when running in debug mode....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Kirya522 NLog ver. 4.6.8 has been released that allows NLog Layout-logic to work for the Instance-property:
https://www.nuget.org/packages/NLog
Created #3579 with example of how to implement NLog Layout magic.