Privacy and cookie policy

Simple report using data from Application Insights

The tool builds an html report starting from an html template containing Kusto Application Insights queries. The queries output is tranformed into html tables or png images and inserted into the final html. The resulting html can be saved locally or easily sent by email after embedding images as "CID:".

Note: the HTML template must be a valid XML file because it will be processed as an xml document (XmlDocument class).

Template fragment tranformed into an html table:

<table border="1" cellspacing="0" cellpadding="3" style="font-size:12px;">
            | where timestamp > ago(1d)
            | summarize _count=sum(itemCount) by type
            | sort by _count desc

Resulting output:

type _count
Script error.3
<table border="1" cellspacing="0" cellpadding="3" style="font-size:12px;">
  <thead style="background-color:lightblue;font-weight:bold;">
      <td align="left">type</td>
      <td align="right">_count</td>
    <tr><td align="left">Script error.</td><td align="right">3</td></tr>
    <tr><td align="left">System.Web.HttpRequestValidationException</td><td align="right">7</td></tr>

Template fragment tranformed into a png:

        | where timestamp > ago(30d)
        | summarize cnt=sum(itemCount) by bin(timestamp, 1d)
        | order by timestamp asc
        | project timestamp, cnt


  <img src="1.png" />

Report Chart

Application ID and Key

You need Application ID and Key values for accessing Application Insights API (Azure Portal --> application insights --> API access)

Create API key

The values can be stored directly inside the html template or somewhere else and pass them explicitelly to the ReportBuilder. In the former case, remember to protect the template file because of sensitive data it contains.

Storing inside html template:

    <meta name="Report_EmailSubject" content="My website report - #DT#" />
    <meta name="Report_ToEmailList" content="foo@localhost#bar@localhost" />
    <meta name="Report_AppInsightID" content="ID..." />
    <meta name="Report_AppInsightApiKey" content="KEY..." />

Note: this configuration meta tag will be removed from the output html.

Output example

Report Output

Original document:
DISCLAIMER: Content and opinions are my own. None of the ideas expressed in this web-site are shared, supported, or endorsed in any manner by my current or former employers. Nothing here should be taken seriously and you understand and accept that you can use any suggestions, ideas, techincal solutions on this web-site only at your own risk. All trademarks are property of their respective owners.