botframework-solutions icon indicating copy to clipboard operation
botframework-solutions copied to clipboard

QnA Service doesn't log metadata into AppInsights

Open neetgupta7 opened this issue 6 years ago • 15 comments

QnA Maker Service

QnA maker services doesn't log MetaData into AppInsight telemetry. Only below info is logged- image

Can this be extended?

neetgupta7 avatar Sep 29 '20 05:09 neetgupta7

@peterinnesmsft Could you please take a look at this?

ninggao avatar Sep 29 '20 18:09 ninggao

@ninggao @peterinnesmsft do you have any updates on this?

neetgupta7 avatar Oct 02 '20 04:10 neetgupta7

I'm not familiar with this issue - did you mean to contact someone else?

petand123 avatar Oct 02 '20 16:10 petand123

@petand123 Apologize, you are not assigned to this issue :)

@peterinnesmsft Could you please take a look at this?

ninggao avatar Oct 02 '20 18:10 ninggao

Investigating this now. Will provide an update later today.

peterinnesmsft avatar Oct 05 '20 19:10 peterinnesmsft

@peterinnesmsft any updates?

neetgupta7 avatar Oct 06 '20 17:10 neetgupta7

Hi @neetgupta7,

Apologies for the delayed response. In taking a look at your request, it appears that you are looking at the 'QnAMaker GenerateAnswer' trace event custom dimensions.

When a user creates a Virtual Assistant, the QnAMaker host that is created amongst your other Azure resources is configured to use the same Application Insights instance as your Virtual Assistant application. As a result, you may see logs which are produced by the QnA application instead of your bot application - the above log entry being one such instance.


If you look within the customEvents table, you can find an event with the name 'QnAMessage' - this is an event that is produced by the underlying QnAMaker service within the Bot Framework SDK, and produces more information beyond the trace event you identified. The corresponding class is Microsoft.Bot.Builder.AI.QnA.QnAMaker, located within the microsoft/botbuilder-dotnet repo.

With this class, it is possible to supply custom event properties and metrics that can be captured within Application Insights. To do this, the recommendation would be to create a custom dialog that inherits from QnAMakerDialog, and add logic as appropriate to supply any additional telemetry properties and metrics.

Let me know if you have any further questions.

peterinnesmsft avatar Oct 07 '20 06:10 peterinnesmsft

@peterinnesmsft Can you pls direct me to content where this is present or some sample will be useful. Just FYI that I am making use of bot builder version 4.7.2-previewsso-103311

neetgupta7 avatar Oct 08 '20 04:10 neetgupta7

@peterinnesmsft Can you pls respond to my prev query.

neetgupta7 avatar Oct 12 '20 04:10 neetgupta7

@peterinnesmsft We are making use of QnAMakerDialog to access QnA service. Is it possible to log metadata through QnAMakerDialog?

neetgupta7 avatar Oct 13 '20 09:10 neetgupta7

Hi @neetgupta7 -- I'm still getting these comments and they need to go to @peterinnesmsft .

petand123 avatar Oct 13 '20 19:10 petand123

@neetgupta7, here are the relevant classes from the microsoft/botbuilder-dotnet repo:

https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Builder.AI.QnA/Dialogs/QnAMakerDialog.cs https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Builder.AI.QnA/QnAMaker.cs

QnAMaker::GetAnswersRawAsync takes in two parameters, telemetryProperties and telemetryMetrics, which I believe can be used to achieve what you are looking to accomplish. As this is currently invoked from the QnAMakerDialog class, which itself doesn't expose an easy way to supply these additional parameters, the recommendation as I made before would be to create a custom implementation over the base QnAMakerDialog that supplies the additional data you are looking for.

peterinnesmsft avatar Oct 14 '20 17:10 peterinnesmsft

rEsolved.

chrimc62 avatar Oct 26 '20 18:10 chrimc62

Please let me know how to include metadata in the insight query for QnAMaker logs somthing as this, here the meatadata field comes empty

requests | where url endswith "generateAnswer" | project timestamp, id, url, resultCode, duration, performanceBucket | parse kind = regex url with *"(?i)knowledgebases/"KbId"/generateAnswer" | join kind= inner ( traces | extend id = operation_ParentId ) on id | extend question = tostring(customDimensions['traces']) | extend answer = tostring(customDimensions['Answer']) | extend score = tostring(customDimensions['Score']) | extend metadata = tostring(customDimensions['qnaMakerOptions']) | project answer,['metadata']

dabgar avatar Sep 23 '21 05:09 dabgar

Can you please share the C# code of the below javascript class shared. for getting the metadata tags in insights @petand123 how to include metadata in the insight query for QnAMaker logs #3843

class CustomQnAMakerDialog extends QnAMakerDialog { async getQnaMakerClient(dialogContext) { const client = await super.getQnAMakerClient(dialogContext); const onQnaResults = client.onQnaResults.bind(client); client.onQnaResults = (qnaResults, turnContext, properties = {}, metrics = {}) => { properties = { ...properties, custom: 'property' }; metrics = { ...metrics, custom: 1.0 }; return onQnaResults(qnaResults, turnContext, properties, metrics); } } }

dabgar avatar Dec 01 '21 09:12 dabgar