Elastic API

Coralogix provides an Elastic API which allows you to query your hosted Elasticsearch instances securely and with ease. 

All you have to do is use your username and password in order to login and get a token, then follow the instructions on the Elastic query API tutorial and get your logs and aggregations from anywhere. 

In order to use ElasticSearch api you must add Coralogix token with each HTTP call.

How to get the token from Coralogix authentication api: 

1) In order to use ElasticSearch api you need to add Coralogix’s token with each HTTP call, Get the token from Coralogix authentication api:


curl -H "Content-Type: application/json" -X POST -d '{"username":"[email protected]","password":"mypassword"}'  https://api.coralogix.com/auth/v1

2) Example of token result: 

{ 
    "token": "reJ0eXAiOiJKV1QiLJhbGciOiJIUzI1NiJ9.eyJpZCI6IjZlMDhkNzIwLTM0YzUtNGMyZC05NTI3LWE0NTlkYjQ2 ZjY3ZiIsInVzZXJuYW1lIjoiUm9ja2.V0UGxheUBjb3JhbG3naXguY29tIiwiY39tcGFueUlkIjoyLCJ0aW1lc3RhbXAiOjE0OTkzNzI2MzIwOTAsImlzU0RLIjpmYWxzZX0dEz5MgXttfp9EcoZmntPHT0EI0eY0L_cKQXat7IN3Pc"
}

3) Query example: 

curl -H 'token: reJ0eXAiOiJKV1QiLJhbGciOiJIUzI1NiJ9.eyJpZCI6IjZlMDhkNzIwLTM0YzUtNGMyZC05NTI3LWE0NTlkYjQ2 ZjY3ZiIsInVzZXJuYW1lIjoiUm9ja2.V0UGxheUBjb3JhbG3naXguY29tIiwiY39tcGFueUlkIjoyLCJ0aW1lc3RhbXAiOjE0OTkzNzI2MzIwOTAsImlzU0RLIjpmYWxzZX0dEz5MgXttfp9EcoZmntPHT0EI0eY0L_cKQXat7IN3Pc' -H "Content-type: application/json" -d '{
	"query": {
		"bool": {
			"must":
			[
				{
					"term": {
						"metadata.applicationName": "PROD"
					}
				},
				{
					"range": {
						"timestamp": {
							"gte": "now-15m",
							"lt": "now"
						}
					}
				}
			]
		}
	},
	"aggs": {
		"severities": {
			"terms": {
				"field": "metadata.severity"
			}
		}
	}
}' 'http://coralogix-kibana.coralogix.com:9300/*/_search'

Elastic API query tutorials: 

1) Search API tutorial

2) Aggregations API tutorial 

Signup to Coralogix
WordPress Lightbox