Elastic search monitor

If this is not the special agent then i don’t know.
You see that your host has the normal TCP connection and the special agent configured.
First step now, execute

/check_mk/agents/special/agent_elasticsearch ‘-P’ ‘https’ ‘-m’ ‘cluster_health nodes stats’ ‘-p’ port number ‘hostname’

With your real parameters. If you get an error you need to solve this error first.

Hi,
the agent_elasticsearch need the cmk python package which is in Class structure of check_mk.
If you want to build a standalone agent yoiu neet to copy the code into agent_elasticsearch and make some little changes.
Regards,
Christian

I don’t understand what you want to do. @martin.schwarz and I said before you should execute the special agent with the “–debug” option to get some error messages if there are errors.
The special agent must be executed inside your monitoring site as the site user.

The agent call with debug option should look like this

/omd/sites/<your site>/share/check_mk/agents/special/agent_elasticsearch --debug -P https -m "cluster_health nodes stats" -p 9200 elastichost

If your port is 9200 and you don’t want to change the queried modules you can omit these options like this

/omd/sites/<your site>/share/check_mk/agents/special/agent_elasticsearch --debug elastichost

Output from my example host

OMD[dev]:~$ cd share/check_mk/agents/special/
OMD[dev]:~/share/check_mk/agents/special$ ./agent_elasticsearch -P http 172.17.120.81
<<<check_mk>>>
<<<elasticsearch_cluster_health>>>
cluster_name docker-cluster
status green
timed_out False
number_of_nodes 1
number_of_data_nodes 1

Hello Andreas,

So the requirement is , we have some Host in which elastic search is there and we need to monitor this and these hosts are added in the Checkmk . we just need to enable the elastic search so that that the number of nodes etc all other services related to elastic search services can be visible along with other services of a host in the Checkmk.

For this we have added the rule following the steps mentioned in the

https://blog.checkmk.com/monitoring-elasticsearch-with-checkmk

Added the rule from “Check state of Elastic Search

But not getting Elastic search related service in service list in checkmk just like the example given in the above link(https://blog.checkmk.com/monitoring-elasticsearch-with-checkmk)

.

Not getting like this elastic search related services in our hosts in Checkmk even after creating the rule for elastic search

I have execute the special agent with the “–debug” option to get some error messages if there are errors.

OMD[dev]:~/share/check_mk/agents/special$ ./agent_elasticsearch --debug -P http hostname “cluster_health nodes stats” -p portnumber
<<<check_mk>>>
<<<elasticsearch_cluster_health>>>
<<<check_mk>>>
Traceback (most recent call last):
File “./agent_elasticsearch”, line 32, in
sys.exit(main())
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 52, in main
handle_request(user, pwd, opt_port, query_objects, opt_proto, opt_debug, elastic_host)
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 78, in handle_request
response = requests.get(url)
File “/dev/lib/python/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/dev/lib/python/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/dev/lib/python/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/dev/lib/python/requests/sessions.py”, line 646, in send
r = adapter.send(request, kwargs)
File “/dev/lib/python/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(’<<<check_mk>>>\n’,))
** return self.scan_once(s, idx=_w(s, idx).end())

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Please help me how to resolve further

Our Elasticsearch is protected with a custom Certificate.
In WATO i cannot configure a root Certificat to use by the elasticsearch agent.
I changed in the file
/omd/sites/du/lib/python/cmk/special_agents/agent_elasticsearch.py
the following:
Line: 76 ( Added verify=False )
response = requests.get(url, auth=(user, pwd), verify=False)

Now the Ageent can connect to elasticsearch protected with a custom Certificate.

Regards,
Peter Rupp

Hello ruppo,

Checked the file agent_elasticsearch.py under /omd/sites/du/lib/python/cmk/special_agents/agent_elasticsearch.py

Below is the screenshot for the same.

So we need to add the (verify=False)
in this if condition
response = requests.get(url, auth=(user, pwd), verify=False)

Will it work . and these files are monitor server already have. So are we suppose to do any changes in this file ?

Never make changes below ~/lib – that’s a symlink into the installed version directory. It might be used by multiple sites at the same time. And changes will be overwritten by future updates.

You can copy the file to ~/local/lib/... and make changes there – if really necessary.

1 Like

Hello Martin,

So the requirement is , we have some Host in which elastic search is there and we need to monitor this and these hosts are added in the Checkmk . we just need to enable the elastic search so that that the number of nodes etc all other services related to elastic search services can be visible along with other services of a host in the Checkmk.

For this we have added the rule following the steps mentioned in the

https://blog.checkmk.com/monitoring-elasticsearch-with-checkmk

Added the rule from “Check state of Elastic Search

But not getting Elastic search related service in service list in checkmk just like the example given in the above link(https://blog.checkmk.com/monitoring-elasticsearch-with-checkmk)

.

Not getting like this elastic search related services in our hosts in Checkmk even after creating the rule for elastic search

I have execute the special agent with the “–debug” option to get some error messages if there are errors.

OMD[dev]:~/share/check_mk/agents/special$ ./agent_elasticsearch --debug -P http hostname “cluster_health nodes stats” -p portnumber
<<<check_mk>>>
<<<elasticsearch_cluster_health>>>
<<<check_mk>>>
Traceback (most recent call last):
File “./agent_elasticsearch”, line 32, in
sys.exit(main())
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 52, in main
handle_request(user, pwd, opt_port, query_objects, opt_proto, opt_debug, elastic_host)
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 78, in handle_request
response = requests.get(url)
File “/dev/lib/python/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/dev/lib/python/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/dev/lib/python/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/dev/lib/python/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/dev/lib/python/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(’<<<check_mk>>>\n’,))
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Please help me how to resolve further

So for the above requirement do we need to do anything along with the rule created to get the elastic search service enabled in the Checkmk and do we need to do anything with agent_elasticsearch and why I am not getting any service related to elastic search in Checkmk like below

.

not sure How to proceed further to get the above

You have not done what i requested and shown as an example in my last post.

This will not work - the last argument must be the host you want to connect to.

from the help

usage: agent_elasticsearch [-h] [-u USER] [-s PASSWORD] [-P PROTO] [-p PORT] [-m MODULES] [--debug] HOSTNAME [HOSTNAME ...]

Please do this and provide the output. What you can do to test if you can reach the elasticsearch instance ist the very easy curl to the isntance.

curl host-ip:port/

This must work if you have no username and password for authentication.

1 Like

Hello @andreas-doehler,

I am getting below error while running
"./agent_elasticsearch -P http -m “cluster_health nodes stats” -p portno --debug hostname"

<<<check_mk>>>
Traceback (most recent call last):
File “./agent_elasticsearch”, line 32, in
sys.exit(main())
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 52, in main
handle_request(user, pwd, opt_port, query_objects, opt_proto, opt_debug, elastic_host)
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 78, in handle_request
response = requests.get(url)
File “/dev/lib/python/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/dev/lib/python/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/dev/lib/python/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/dev/lib/python/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/dev/lib/python/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(’<<<check_mk>>>\n’,))

And while running

"curl host-ip:port/"

getting below error

ERROR

The requested URL could not be retrieved


""

I hope this is a bad joke?
You didn’t really leave host-ip and port in the test?

It would be good to replace this with the real values. The same for the special agent, i don’t think that you elasticsearch host hast the name “hostname” or that “hostname” is a resolvable host name.

Hello @andreas-doehler,

previously also I have replaced the hostname with my hostname and and port no with my port number in both the curl and special agent query
"./agent_elasticsearch -P http -m “cluster_health nodes stats” -p portno --debug hostname"

below is the error I am getting

<<<check_mk>>>
Traceback (most recent call last):
File “./agent_elasticsearch”, line 32, in
sys.exit(main())
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 52, in main
handle_request(user, pwd, opt_port, query_objects, opt_proto, opt_debug, elastic_host)
File “/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 78, in handle_request
response = requests.get(url)
File “/dev/lib/python/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/dev/lib/python/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/dev/lib/python/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/dev/lib/python/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/dev/lib/python/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(’<<<check_mk>>>\n’,))

??? there is nothing replaced
Please give your command what you execute and the output and not the copy and past from old posts.

1 Like

Hello @andreas-doehler ,

Due to some policy we can’t reveal the hostnames. But I have replaced the command with our hostname and port number
below is the error we are getting

<<<check_mk>>>
Traceback (most recent call last):
File “./agent_elasticsearch”, line 32, in
sys.exit(main())
File “/omd/sites/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 52, in main
handle_request(user, pwd, opt_port, query_objects, opt_proto, opt_debug, elastic_host)
File “/omd/sites/dev/lib/python/cmk/special_agents/agent_elasticsearch.py”, line 78, in handle_request
response = requests.get(url)
File “/omd/sites/dev/lib/python/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/omd/sites/dev/lib/python/requests/api.py”, line 60, in request
return session.request(method=method, url=url, **kwargs)
File “/omd/sites/dev/lib/python/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/omd/sites/dev/lib/python/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/omd/sites/dev/lib/python/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(’<<<check_mk>>>\n’,))

If i don’t see the command you issue then it is not possible to help.
The same for the curl command if i don’t see what you do then no help possible.

I showed with my example how it must look like.

1 Like

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