Latency


(Asha Angalla) #1

GET mule-*/_search

{

"query":{

"exists": { "field": "mule.api.analytics.repliedTs" }

},

"script_fields" : {

"totalRequestTime" : {

"script" : {

"inline": "((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S").parse(doc['mule.api.analytics.repliedTs'].value).getTime()) - (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S").parse(doc['mule.api.analytics.receivedTs'].value).getTime())) ;"

}

}

}

}

The given script is working in kibana Dev Tools however we can’t use the same script for visualization that we need to generate new field by using Kibana painless script. However while generating new fields for latency to convert the string into number/Timestamp. It doesn’t convert into number, I have also tried another way to generate latency field by importing JSON it also it did not work. Could find these issue anywhere is the resources as well.

Help would be appreciated.

Thank you,

Asha.


(Bill McConaghy) #2

It looks like that painless script should work for a Kibana scripted field if you convert the " entities to ".


(Asha Angalla) #3

Thank you for the reply,

GET mule-*/_search

{

"query":{

"exists": { "field": "mule.api.analytics.repliedTs" }

},

"script_fields" : {

"totalRequestTime" : {

"script" : {

"inline": "((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S").parse(doc['mule.api.analytics.repliedTs'].value).getTime()) - (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S").parse(doc['mule.api.analytics.receivedTs'].value).getTime())) ;"

}

}

}

}

this one also din't work, could you please help me with the same.


(Asha Angalla) #4

Hi Bill,

Latency issue is not resolved yet, could you please help me with the same.

I’ll look forward for your reply.

Thank you,

Asha.


(Bill McConaghy) #5

I'm not exactly sure what you are trying to do, or what you've tried so far. I would suggest looking at this guide on how to create a scripted field in Kibana: https://www.elastic.co/guide/en/kibana/current/scripted-fields.html . If you add a scripted field to your index pattern you should be able to use it in a visualization.


(Asha Angalla) #6

Bill, I was able to create the filed for Latency through painless scripts, however I am not able to get the data in the Discover field where we get the data in the tables.


(Asha Angalla) #7

In my project repTs and RecTs are in String Type and I couldn’t convert them from string to number(data) with the below painless script.

Script:

(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S").parse(doc['mule.api.analytics.repliedTS.keyword'].value).getTime()) - (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S").parse(doc['mule.api.analytics.receivedTS.keyword'].value).getTime())

Please help me with the same as I need to finish high prior report due Today.

I would be grateful if you could help me with the same.

Thank you in Advance.


(Bill McConaghy) #8

Did you look at the scripted field documentation referenced above? This is how you can create a field in Painless and have it be available in discover or visualizations.


(Asha Angalla) #9

Yes, the script I created and the one which is the scripted filed documentation both are same. Now my question is why am I not able to convert the string to number or date in the Index pattern


(Bill McConaghy) #10

If those fields contain numbers they should be mapped as numbers in Elasticsearch. You will need to reindex to accomplish this.


(Asha Angalla) #11

Please find the attachment as field are in numbers even then I find string in data type, what would you suggest?


(Asha Angalla) #12

Now in this situation should Elasticsearch admin in my project reindex to accomplish this?

Please suggest me.


(Asha Angalla) #13

Is there any there way we could figure this out other then reindexing. Please let me know. Thank you


(Asha Angalla) #14

Or else will it be possible to give me a call to discuss regarding the same this has highest priority to complete.


(Asha Angalla) #15

I was able to create latency filed with the script below: doc['mule.api.analytics.repliedTs'].value.getTime() -
doc['mule.api.analytics.receivedTs'].value.getTime()
However when i choose latency filed it has the warning mentioned below:
This field is present in your elasticsearch mapping but not in any documents in the search results. You may still be able to visualize or search on it.


(Asha Angalla) #16

I was able to create latency filed with the script below: doc['mule.api.analytics.repliedTs'].value.getTime() -
doc['mule.api.analytics.receivedTs'].value.getTime()
However when i This field is present in your elasticsearch mapping but not in any documents in the search results. You may still be able to visualize or search on it.


(system) closed #17

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.