CRM and CX Blogs by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
cancel
Showing results for 
Search instead for 
Did you mean: 
KirtiKumbhati
Discoverer
Problem Statement :

Introduce Alerts mechanism in Kibana and integrate with Teams channel

a. For HTTP Errors
b. For Performance

 

For HTTP Errors

Query Preparation for Error Extraction

  1. Prepare the Query in "Query workbench and do the explain ,Copy this Json somewhere


Select count(*) from logs-json-* where logs.status >= 400 and logs.localServerName is "api.cuxuzunfzu-public.model-t.cc.commerce.ondemand.com" and logs.requestFirstLine LIKE "%electronics%"

 

Where electronics is Site ID for which you want to monitor errors  on api Node . You can customize the Query based on  your needs

Translated JSON looks like this
{
"from": 0,
"size": 0,
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"bool": {
"must": [
{
"range": {
"logs.status": {
"from": 400,
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
},
{
"term": {
"logs.localServerName.keyword": {
"value": "api.cuxuzunfzu-public.model-t.cc.commerce.ondemand.com",
"boost": 1
}
}
},
{
"wildcard": {
"logs.requestFirstLine": {
"wildcard": "*electronics*",
"boost": 1
}
}
},
{
"range": {
"time": {
"from": "now-10m",
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"_source": {
"includes": [
"COUNT"
],
"excludes": [

]
},
"aggregations": {
"COUNT_0": {
"value_count": {
"field": "_index"
}
}
}
}
You can also change the wildcard from exact match Translated json like this


  1. Please update the wildcard query with match-phrase query in above Json.


WildCard Query:
   "wildcard": {
"logs.requestFirstLine": {
"wildcard": "*electronics*",
"boost": 1
}
}


Match Phrase Query:
  "match_phrase": {
"logs.requestFirstLine": {
"query": "electronics",
"boost": 1
}
}

Note: If we have to use hyphen "-" is not recognized as a character in the LIKE/WILDCARD query, so you can use MATCH_PHRASE instead. If you want to monitor error occured in last 10m or nay frequency this is the code Snippet {
"range": {
"time": {
"from": "now-10m",
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
}
} The above Jso has to copied in Extraction Query after craeting the montor Create the Monitor like below Create the Trigger condition You can define priorty based on your business needs like in 10 mins more that 5 erros are high alerts Here in below example any error is High

Create the Action


 

Give mandatory details and Select Destination

 

Add teams destination 

Select the teams channel configuration

Teams specific task

1. You have to create the teams channel

2. Add the App name in there Incoming Webhook this will give you Webhook URL which you can use for the Teams alert integration.

You have to add new Destination


 

Add new Desination  and add the above webhookURL below


Create the message which you want to share on teams once alerts occur and Copy in Action Message steps

 
{
"@type":"MessageCard",
"@context":"https://schema.org/extensions",
"summary":"Error for ELECTRONICS",
"themeColor":"FF0000",
"sections":[
{
"activityImage":"URL",
"activityTitle": "Errors Produced for ELECTRONICS SITE in Last 10 minutes ",

"facts":[
{
"name":"Reason: ",
"value":"ERROR-CODE - More than 400. <b>Number of Occurrences: {{ctx.results.0.hits.total.value}}</b>""
}
],
"text":"Api Calls failed.",
"potentialAction":[
{
"@type":"OpenUri",
"name" : "Check Kibana",
"targets":[
{
"os":"default",
"uri":"URL FOR KIBANA "
}
]
}

]
}
]
}


b. For Performance

All the steps are same except the Query extraction are same . Query extraction which has to be done very carefully

Create your Query For example I have created the Query which
a.Fetch API from ELECTORNICS which are taking more than 3 seconds
SELECT count(*)  FROM logs-json-* where logs.responseTime  is not null and logs.localServerName is "api.cuxuzunfzu-public.model-t.cc.commerce.ondemand.com" and logs.requestFirstLine like "%ELECTRONCIS%" 
and CAST(logs.responseTime AS INTEGER) > 3000



{
"from": 0,
"size": 0,
"query": {
"bool": {
"filter": [
{
"bool": {
"filter": [
{
"bool": {
"filter": [
{
"script": {
"script": {
"source": "XXXXXXXXXXXXXcWwuZXhwcmVzc2lvbi5mdW5jdGlvbi5GdW5jdGlvbkRTTCQy7+eYHhdeXG4CAARMAA12YWwkYXJndW1lbnRzdAAQTGphdmEvdXRpbC9MaXN0O0wADHZh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ylMb3JnL29wZW5zZWFyY2gvc3FsL2RhdGEvbW9kZWwvRXhwclZhbHVlO3EAfgAncQB+ABl+cgApb3JnLm9wZW5zZWFyY2guc3FsLmRhdGEudHlwZS5FeHByQ29yZVR5cGUAAAAAAAAAABIAAHhxAH4AFXQAB0JPT0xFQU4=",
"lang": "opensearch_query_expression"
},
"boost": 1.0
}
},
{
"wildcard": {
"logs.requestFirstLine.keyword": {
"wildcard": "*ELECTRONICS*",
"boost": "1.0"
}
}
}
],
"adjust_pure_negative:true,boost": "1.0"
}
},
{
"wildcard": {
"logs.requestFirstLine.keyword": {
"wildcard": "*locationId*",
"boost": "1.0"
}
}
},
{
"range": {
"time": {
"from": "now-10m",
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
}
],
"adjust_pure_negative": "true",
"boost": "1.0"
}
},
{
"script": {
"script": {
"source": "XXXXXXXX/macCAARMAA12YWwkYXJndW1lbnRzdAAQTGphdmEvdXRpbC9MaXN0O0wADHZhbCRmdW5jdGlvbnQAP0xvcmcvb3BlbnNlYXJjaC9zcWwvZXhwcmVzc2lvbi9mdW5jdGlvbi9TZXJpYWxpemFibGVCaUZ1bmN0aW9uO0wAEHZhbCRmdW5jdGlvbk5hbWV0ADVMb3JnL29wZW5zZWFyY2gvc3FsL2V4cHJlc3Npb24vZnVuY3Rpb24vRnVuY3Rpb25OYW1lO0wADnZhbCRyZXR1cm5UeXBldAAnTG9yZy9vcGVuc2VhcmNoL3NxbC9kYXRhL3R5cGUvRXhwclR5cGU7eHIAMG9yZy5vcGVuc2VhcmNoLnNxbC5leHByZXNzaW9uLkZ1bmN0aW9uRXhwcmVzc2lvbrIqMNPcdWp7AgACTAAJYXJndW1lbnRzcQB+AAFMAAxmdW5jdGlvbk5hbWVxAH4AA3hwc3IAE2phdmEudXRpbC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAJ3BAAAAAJzcgA0b3JnLm9wZW5zZWFyY2guc3FsLmV4cHJlc3Npb24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ations": {
"count(*)": {
"value_count": {
"field": "_index"
}
}
}
}


DO the Explain and copy the inner translated json in New Performance Error monitor



Top kudoed authors