Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application Insight: Use graphs that use "zero-fill" #6664

Open
ramonsmits opened this issue May 27, 2024 · 0 comments
Open

Application Insight: Use graphs that use "zero-fill" #6664

ramonsmits opened this issue May 27, 2024 · 0 comments

Comments

@ramonsmits
Copy link
Member

Feedback for 'Monitoring NServiceBus endpoints with Application Insights' https://docs.particular.net/samples/open-telemetry/application-insights/

Location in GitHub: https://github.com/Particular/docs.particular.net/blob/master/samples/open-telemetry/application-insights/sample.md

Many metrics are updated based on message that are processed. When there are no incoming messages there are no metrics to report. By default, Azure Monitor / Application Insights will not set the value to 0 on graphs steps/intervals for which no metric data was capture. This results in strange graphs.

In ServicePulse graphs are "zero-filled" when no data is received in a step/interval.

This isn't easy to accomplish with Azure Monitor and requires custom KQL via the "range" operator

Using range operator to achieve zero-fill graphs:

let defaultValue = 0.0;
range timestamp from floor(ago(30m),1m) to floor(now(),1m) step 1m
| join kind=leftouter
(
    customMetrics
    | where timestamp >= ago(30m) and timestamp < now()
    //| where name == "nservicebus.messaging.processingtime"
    //| where name == "nservicebus.messaging.criticaltime"
    //| where name == "nservicebus.messaging.failures"
    | where name == "nservicebus.messaging.successes"
    | where customDimensions has "Store.Operations"
    | extend
        customMetric_valueSum = iif(itemType == 'customMetric', valueSum, todouble(''))
        //,customMetric_valueCount = iif(itemType == 'customMetric', valueCount, toint(''))
    //| summarize Value = sum(customMetric_valueSum) / sum(customMetric_valueCount) by bin(timestamp, 1m)
    | summarize Value = sum(customMetric_valueSum) by bin(timestamp, 1m)
    | order by timestamp desc
) on timestamp
| project timestamp, value = iff(isnotempty(Value), Value, defaultValue)
| render areachart

Original solution found at https://stackoverflow.com/a/50537449/199551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant