I am having a hard problem. Logstash+Kibana are being used for logs but these logs are also rich and full of metrics.
In particular NGINX HTTP endpoint metrics.
I am having a difficult time crafting the right python queries to get the metrics I need to extract.
For example, in Kinana I have the string
GET "/user/685934468/api/v1/tables/funds_raised_map_by_region_1
What I need is
- String must contain /user/
- String must contain /api/v1/tables/
- String must_not contain any known datasets in known_array = []
I need to first pull the right logs but I am missing lots of valid entries. Here is my query string on the Kibana searchbox
/user/ AND /api/v1/tables/ AND NOT (funds_raised_map_by_region total_solar_eclipse_2017_local_time OR shared_empty_dataset OR factories)
This returns the right data (near as I can tell) in the Kibana UI.
However when I look at the underlying HTTP call being sent, and I copy/paste the below query into Python and send
import elasticsearch
es = elasticsearch.Elasticsearch('http://' + self.host_name + ':' + str(self.port_number))
results = es.search(
index=elastic_index,
body={
'size': 100000,
'query': {
'filtered': {
'query': {
'query_string': {
'default_field' : 'message',
'query': sQuery,
'analyze_wildcard': 'true'
}
}
}
}
}
)
Here is the Elastic search request object.
{
"index": ["development-2018.02.13"],
"ignore_unavailable": true
}{
"size": 500,
"sort": [{
"@timestamp": {
"order": "desc",
"unmapped_type": "boolean"
}
}
],
"query": {
"filtered": {
"query": {
"query_string": {
"query": "/user/ AND /api/v1/tables/ AND NOT (funds_raised_map_by_region total_solar_eclipse_2017_local_time OR shared_empty_dataset OR factories)",
"analyze_wildcard": true
}
},
"filter": {
"bool": {
"must": [{
"range": {
"@timestamp": {
"gte": 1518498000000,
"lte": 1518584399999,
"format": "epoch_millis"
}
}
}
],
"must_not": []
}
}
}
},
"highlight": {
"pre_tags": ["@kibana-highlighted-field@"],
"post_tags": ["@/kibana-highlighted-field@"],
"fields": {
"*": {}
},
"require_field_match": false,
"fragment_size": 2147483647
},
"aggs": {
"2": {
"date_histogram": {
"field": "@timestamp",
"interval": "30m",
"time_zone": "America/New_York",
"min_doc_count": 0,
"extended_bounds": {
"min": 1518498000000,
"max": 1518584399999
}
}
}
},
"fields": ["*", "_source"],
"script_fields": {},
"fielddata_fields": ["@timestamp"]
}