How to get the Qna Maker "Q" from Analytics Application Insights? - azure

I have created my chatbot's knowledge base with Qna Maker and I am trying to visualize some statistics with Analytics Application Insights.
What I want to do
I would like to create a chart with the most requested Qna Maker questions.
My problem
I can't find the Qna Maker questions in the customDimensions traces on Analytics but only their Id :
My question
Is their a way to get the Qna Maker Question linked to this Id directly from the Analytics Application Insights tool ?
Thank you.
PS : I had to use "Q" instead of "Question" in the title due to Stackoverflow rules.

Not directly.
the only info you have in appinsights is whatever was submitted with the data. so if they aren't sending the question (odd that they send the answer but not the question?) then you're out of luck.
As a workaround, you could create a custom table in your application insights instance:
https://learn.microsoft.com/en-us/azure/application-insights/app-insights-analytics-import
and populate that table with the id and question.
then you could join those two things in analytics queries in the analytics tool or in workbooks.

if you're looking for a query with question and answer linked through id, here is your answer:
requests
| where url endswith "generateAnswer"
| project timestamp, id, name, resultCode, duration
| parse name with *"/knowledgebases/"KbId"/generateAnswer"
| join kind= inner (
traces | extend id = operation_ParentId
) on id
| extend question = tostring(customDimensions['Question'])
| extend answer = tostring(customDimensions['Answer'])
| project KbId, timestamp, resultCode, duration, question, answer
This doesn't necessarily solve your issue but might be of help for other people looking for a simple report of question/answer to improve their QnA maker.
The sample could be found in the official documentation:
https://learn.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/get-analytics-knowledge-base

Here is a query that I came up with that will pull in the id of the knowlegebase question, the question the user typed, and the knowlegebase anwer. It also ties multiple questions together if they are from the same session.
I have not yet been able to find a way to identify a way to get the knowlegebase question associated to the id though.
requests
| where url endswith 'generateAnswer'
| project id, url, sessionId = extract('^[a-z0-9]{7}', 0, itemId)
| parse kind = regex url with *'(?i)knowledgebases/'knowlegeBaseId'/generateAnswer'
| join kind= inner
(
traces
| extend id = operation_ParentId
| where message == 'QnAMaker GenerateAnswer'
| extend userQuestion = tostring(customDimensions['Question'])
| extend knowlegeBaseQuestionId = tostring(customDimensions['Id'])
| extend knowlegeBaseAnswer = tostring(customDimensions['Answer'])
| extend score = tostring(customDimensions['Score'])
)
on id
| where timestamp >= ago(10d)
| project knowlegeBaseId, timestamp, userQuestion, knowlegeBaseQuestionId, knowlegeBaseAnswer, score, sessionId
| order by timestamp asc

Related

Application insight - How can I make left join from request to bind with exceptions via Kusto language?

I have a simple question for kusto language expert for rejecting Custom values from requests and binding with an exception I am seeing these values from simple queries but in the below queries:
I have only 2 custom fields :
source
subject
How can I add this result? What am I missing? I made some research for an answer by googling but I didn`t find any exact answer.
requests
| extend source= tostring(customDimensions["source"]), orderID= tostring(customDimensions["subject"])
| where timestamp > ago(30d)
| where success == False
| project name, operation_Id, StartTime=timestamp, orderID, source
| join ( exceptions
| project timestamp, problemId,type,method,outerMessage,outerMethod,innermostType,innermostMessage,severityLevel,details,customDimensions,operation_Name,operation_Id,operation_ParentId
) on operation_Id
| evaluate autocluster()
I have used your query to reproduce. I am able to fetch the required result.
Workaround follows:
The result before Join the request and exception
No. of False Success Result in my AI
Using Join:
Using left join
use join kind=leftsemi. It returns the left which match with the right. Refer MS-Doc for join flavor to do require join operation.

How to describe a scenario in gherkin retrieving an Access Token in Given clause

My question is much more conceptual than ever. I'd like to describe a good scenario using the Cucumber feature file where I have to have for each row of my Data table a new access token from the Identity Provider.
I.e
Scenario:
Given <Code Authorization>
And <Access Token>
And The client has the following information
| email | FirstName | Phone |
| xpto# | Richard | 343242|
When the client via Post /xpto
Then The API response a Json file
| code | response |
| 200 | xpto |
I'll use a Data Table for this kind of approach. However, I cannot give a static Access Token because it will expire. I should get a new one every time when my test run but It is not my test it self. The Token is just a Data that I have to have to test my scenario.
Is it ok call a REST in an Given Step? If I do this I am mixing up the objective of my scenarios.
Any thougts are welcome not for your mind but by the book. :-)
Kind Regards,
It seems that you need the token in order to set up the scenario. In that case it is fine to have that in a Given step. You can perform REST or other calls in step definitions for that Given step. For ex: It may look something like below. You can change wordings as you like but try to word it in a manner that shows initial state of the application.
Given I have a token for this scenario
And The client has the following information
| email | FirstName | Phone |
|xpto# | Richard | 343242|
...
...
Given steps are meant to establish a given state. It is considered best practice in BDD. You can find this information in official BDD docs here
Also , if you want to read more about the purpose and structure of Given , When and Then , be sure to have a look here

Filter data from CustomEvent

I have data in azure Insights saved in custom events formats.
Now I need to create a dashboard page in my website that will pull data from insights and will show graphs on that data.
Questions is that how I can filter data from the customEvents based on data saved there. like based on custom events or custom data.
Provide me any resource from where I can see that how $filer, $search,$query works?
I am here https://dev.applicationinsights.io/quickstart but not looks like enough.
I tried to add filter like
startswith(customEvent/name, 'BotMessageReceived')
in https://dev.applicationinsights.io/apiexplorer/events
but it not working. is says "Something went wrong while running the query",
I have customEvents which name start with BotMessageReceived
Thanks
Dalvir
update:
There is no like operator, if you wanna use timestamp as a filter, you should use one of the three methods below:
customEvents
| where timestamp >= datetime('2018-11-23T00:00:00.000') and timestamp <=
datetime('2018-11-23T23:59:00.000')
customEvents
| where tostring(timestamp) contains "2018-12-11"
customEvents
| where timestamp between(datetime('2018-11-23T00:00:00.000') ..
datetime('2018-11-23T23:59:00.000') )
Please use this:
customEvents
| where name startswith "BotMessageReceived"
And if you use the api you metioned above, you can use:
https://api.applicationinsights.io/v1/apps/Your_application_id/query?
query=customEvents | where name startswith "BotMessageReceived"
It works at my side.

How to create comments in Azure Log Analytics

I'm trying to create comments in my Azure Log Analytics queries and I'm stumped. Part of my challenge I think is treating this system as if it were SQL, which it is clearly not. using "--" for instance results in a syntax error
traces
| where severityLevel > 1
-- this is an example of a line comment
| where message !contains "DiagnosticsLogger.GetMethod contains message 1"
| where message !contains "DiagnosticsLogger.GetMethod contains message 2"
| summarize by timestamp, message, severityLevel
Couldn't find anything for search term "Comment" either on the https://docs.loganalytics.io reference.
// works for Azure Log Analytics queries

Sequelize - Is there any way to do Data Abstraction/Filtering?

First at all, I'm sorry if I'm re-posting, but I couldn't find anything related.
I'm working on a application that handle very sensitive data. I want to filter this data by user's role.
I've done this (in another job) using Doctrine Filters, but I can't find any information about how to do this using Sequelize (over PostgreSQL).
Eg:
sensitive_information:
| user_id | sensible_value |
+---------+----------------+
| 1 | something |
| 2 | something_else |
I need this:
SELECT *
FROM sensitive_information
WHERE user_id = 1; /** I need this to be added automatically in all
queries to sensitive_information */
So, user 1 never will see information of another user. That's the goal.
Is it possible? I'm open to suggestions.
Thanks in advance.
This can be addressed by using Sequelize scopes.
Since scopes can be functions:
Scopes are defined in the model definition and can be finder objects, or functions returning finder objects
it's easy to define a scope that filters information according to the user that is logged in.
I haven't implemented this exactly scope yet but I have a good idea on how to address it if anyone needs helps with it.

Resources