How do I encode queries for Application Insights deep links using Python?

Lord Wolfenstein 46 Reputation points
2024-04-23T17:57:58.11+00:00

In my Application Insights logs I can click this and get deep link I can share with everyone that that have access.

User's image

In the end of the URL I get there is /q/ followed by an unreadable string that is the encoded query. If I know the query is

traces
| where customDimensions.message_uuid contains "my-uuid"
| project
message,
timestamp,
message_uuid = customDimensions.message_uuid

how do I encode it using Python to fit in the deep link azure give me?

What I am trying to achieve is a way to generate simple clickable links that take me directly to the error if I know the query.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
0 comments No comments
{count} vote

Answer accepted by question author
  1. Stuart Leeks 81 Reputation points
    2024-04-29T09:51:33.65+00:00

    @Lord Wolfenstein I came across your question as I was asking the same question myself.

    I've written up a blog post with the approach I've taken: https://stuartleeks.com/posts/deep-linking-to-queries-in-application-insights-with-python/

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.