I managed to connect my bot's telemetry with Azure Application Insights. I am now trying to make it so the Application Insights can show certain values from the bot (example: a user's input). I assume this would be related to custom events, but after looking at documentations, I am still really confused and do not know how to set it up to log the values.
The bot framework itself has a way to write telemetry to an Application Insights instance. I believe this is what you've configured and have working so far. For writing custom events/metrics you would want to simply utilize the AI TelemetryClient yourself like you would in any other .NET Core application.
Once registered, you would change your IBot class to take TelemetryClient as a dependency to its constructor which will then be injected for you and then you just start recording events/metrics as you normally would.
The real question I always like to ask is: do you really want to tightly couple yourself directly to the Application Insights APIs? Do you perhaps just want to have a certain level of logging that you're doing through the logging abstraction (e.g. ILogger[<T>])? Or, if you need events, perhaps you want to use an EventSource instead. Both of these abstractions can then be captured by Application Insights by configuring the appropriate telemetry modules, but they do not tie your code directly to Application Insights itself. I believe the only thing that doesn't have a good existing abstraction would be if you needed to gather metrics. You could of course still build your own abstraction for that and then a custom module that funnels the details into AI.
Related
I currently have a microservice architecture consisting of ~20 services at the moment and each service has its own dedicated application insights instance per environment (dev/test/prod).
What I would like to do, if possible, is aggregate all of the different application maps into one global application map so that I can easily see everything through a single pane of glass (per environment) rather than having to drill into each individual service's application map.
The only way to do this, from what I've found, is to have ever service point to the same app insights resource. However, I would imagine that this approach would make it difficult to easily track metrics for an individual service, since the metrics would be based off the entire environments architecture rather than each service. Is there some way to build a workbook that combines all of the application maps?
Any ideas on how to approach this? Thanks in advance.
If your microservices are instrumented with Application Insights SDKs and rely on auto instrumentation then it should work out of the box. Application Insights will discover which components a particular app talks to and you should be able to get the full map by clicking on "Update map components".
One app view:
Whole connected microservice universe view:
If "Update map components" is greyed out then something wrong with distributed tracing instrumentation.
I have a solution in Azure that has multiple networking components, and am trying to trace requests through from component to component. I have enabled a LogAnalyticWorkspace that these components output to.
Application Gateway w/ WAFv2,
API Management Instance,
Application Gateway w/o WAF,
Container Instance,
AppGW-WAF-->APIM-->AppGW-->Container
Is there some common attribute/header value/query string addition, etc. that I can use in the LAW to trace a request from point to point in the sequence above?
Any advice is appreciated!
it sounds like you want to do tracing on the application / HTTP layer to get something like this?!
Then you want to look at Application Insights and Correlation, probably using distributed tracing.
This also nicely integrates out of the box with APIM.
I have built WPF and Electron desktop applications where I'm currently logging custom usage and error logs. They are sent to an Azure Function which in turn talks to an Azure MSSQL database with a stored procedure to add log messages.
I feel this is not a very optimal solution. The function sometimes takes a long time to spin up, and the database potentially feels a bit overkill for logging (maybe it's OK). And I don't know if it's safe to add the link to the logging function in my applications even though it's very restrictive in what it accepts. You need to send the logs in a specific structure with some mandatory fields. But this feels more like "security by obscurity".
Isn't there a better way to implement a centralized logging service for my different applications? I want to be able to add more applications in the future as well (all will send the same structured logs). Are there any features in Azure to handle custom logging?
I read about the difference between log-based and pre-aggregated metrics here:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/pre-aggregated-metrics-log-metrics
Later on I came across event counters:
https://learn.microsoft.com/en-us/azure/azure-monitor/app/eventcounters
They both seem to be used to track metrics of some kind. I see the EventCounters documentation doesn't mention any (pre-)aggregation, but besides that, what is the difference between both and when do I use an EventCounter rather than making a call to TelemetryClient.TrackMetric()?
TelemetryClient.TrackMetric() is specific to application insights, EventCounter is not.
EventCounter is a mechanism in .Net to define custom metrics inside an application/library. You have to create a listener for them to read out the values and possible send those values somewhere. This could be a simple console output, a logging framework or something else like Application Insights. It decouples the generation of metric from the consumption of those metrics.
If an application or library you are using already defines metrics using EventCounters you can publish them as metrics in Application Insights. The referenced documentation tells you how to do that.
If you write your own code and what to track custom metrics in Application Insights you can decide yourself. Using TrackMetric is the fastest and easiest option but you might loose some flexibility when you want to publish the metrics somewhere else.
I wrote a blogpost about EventCounters a while ago, if you're interested in the why and the how.
I heave created a query in (the wonderful tool ) Application Insight Analytics which I intended to use for monitoring in one way or another, but from what I found, this is not that easy?
The query returns some data I would like to set up Application Insight alerts on (such as if (column1 equals '1') then alert() or if(column2 > 10) then alert().
Or if that is not possible, is the Analytics service available either from .net code or power shell? If so, I would be able to create the alert-service myself (not ideal though).
Is any of the above features available?
(I do not think the functionality I´m after is available in Insights. I want to compare two custom events and based on differences between them, take actions if necessary)
There's currently no way to get azure alerts from an Analytics query.
However, there is a request for that on uservoice:
https://visualstudio.uservoice.com/forums/357324-application-insights/suggestions/14428134-add-alerts-based-on-results-of-analytics-queries
so go upvote and comment on that to make your voice heard.
There's also a planned service to read data from Analytics through an API as well:
https://visualstudio.uservoice.com/forums/357324-application-insights/suggestions/4999529-make-data-accessible-via-apis-for-custom-processin
Which you could write your own service against to do extra work.