No Handlers could be found for logger "elasticsearch"

I have created a python script to create snapshot on elasticsearch including elasticsearch-curator library. How ever this script worked perfectly more than one year and suddenly I got following error. I tried adding logger code inside my script. But same observed.

How do I resolve this issue ?

[root@log-server backup_scripts]# python manual_snap.py

CREATING SNAPSHOT STARTED
No handlers could be found for logger "elasticsearch"
ERROR IN CREATING SNAPSHOT OF elasticindex_2000 
ConnectionError(('Connection aborted.', error(104, 'Connection reset by peer'))) caused by: ProtocolError(('Connection aborted.', error(104, 'Connection reset by peer')))
MANUALLY CREATE SNAPSHOT OF INDICIES ENDED

Below is my python script.

#!/usr/bin/env python

from elasticsearch import Elasticsearch
import curator

indices_list = [2000, 2001]

for indi in indices_list:

  REPOSITORY = 'index_backup'
  SOURCE = 'creation_date'
  DIRECTION = 'older'
  UNIT = 'days'
  UNIT_COUNT = 10
  INDEX_NAME = 'elasticindex_' + str(indi)

  print "CREATING SNAPSHOT STARTED"

  es = Elasticsearch(['http://192.166.5.1', 'http://192.168.5.2'], port=9200, timeout=3600)

  try:
	ilo = curator.IndexList(es)
	ilo.filter_by_age(source=SOURCE, direction=DIRECTION, unit=UNIT, unit_count=UNIT_COUNT)
	ilo.filter_by_regex(kind='prefix', value=INDEX_NAME)
	snap_indicies = curator.Snapshot(ilo, REPOSITORY, INDEX_NAME, skip_repo_fs_check=True)
	snap_indicies.do_action()

	get_snapshot_state = snap_indicies.get_state()
	if get_snapshot_state == 'SUCCESS':
		print "CREATING SNAPSHOT ENDED"
		print "SUCCESSFULLY CREATE SNAPSHOT OF " + INDEX_NAME
	else:
		print "FAILED TO CREATE SNAPSHOT OF " + INDEX_NAME
  except Exception as snapindicies:
		print "ERROR IN CREATING SNAPSHOT OF " + INDEX_NAME, snapindicies

print "MANUALLY CREATE SNAPSHOT OF INDICIES ENDED \n"

Not having an actual logger means not having insight into what Curator and the Elasticsearch python module are doing—particularly the connection activity. Curator logging also includes timestamps, so you can see how long API calls are taking.

The ConnectionError error is therefore harder to diagnose. You are getting:

ConnectionError(('Connection aborted.', error(104, 'Connection reset by peer'))) caused by: ProtocolError(('Connection aborted.', error(104, 'Connection reset by peer')))

Your script is attempting to connect to 192.166.5.1 and 192.168.5.2. The second IP is non-routable, an internal IP address. The first IP however, is external. I’m going to go out on a limb and suggest that the first IP should read 192.168.5.1 — a 168 instead of the 166. The error message indicates it cannot connect to 192.166.5.1, which probably doesn’t have an Elasticsearch instance running on port 9200.

Additionally, you are including http in your hosts, but no port. When including the http you should include the port at the end of the line, e.g. http://192.168.5.2:9200, and omit the port=9200 from the client definition.

So, my recommendation is to make the line:

es = Elasticsearch(['http://192.168.5.1:9200', 'http://192.168.5.2:9200'], timeout=3600)

and give it a try with that.

Due to privacy I have replace my original IP address with private address. There is no issue with the

es = Elasticsearch(['http://192.168.5.1:9200', 'http://192.168.5.2:9200'], timeout=3600)

In my production environment, both node IP addresses are in same subnet.

So, what happens if you run

curl http://w.x.y.z:9200

From the same machine where Curator is not running?

Image%206

Image%207

See the above output

That looks like a browser. I mean for you to run curl at the console on the machine where you’re trying to run Curator.

curl output give following result,

curl http://xxx.xxx.xxx.16:9200

Notification: Proxy Authorization Required body { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color:#333333; background-color: #ffffff; } h1 { font-size: 18px; font-weight: bold; text-decoration: none; padding-top: 0px; color: #2970A6; } a:link { color: #2970A6; text-decoration: none; } a:hover { color: #2970A6; text-decoration: underline; } p.buttonlink { margin-bottom: 24px; } .copyright { font-size: 12px; color: #666666; margin: 5px 5px 0px 30px;

}
.details {
font-size: 14px;
color: #969696;
border: none;
padding: 20px 20px 20px 20px;
margin: 0px 10px 10px 35px;
}

.shadow {
border: 3px solid #9f9f9f;
padding: 10px 25px 10px 25px;
margin: 10px 35px 0px 30px;
background-color: #ffffff;
width: 600px;

-moz-box-shadow: 3px 3px 3px #cccccc;
-webkit-box-shadow: 3px 3px 3px #cccccc;
box-shadow: 3px 3px 3px #cccccc;
/* For IE 8 /
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='cccccc')";
/
For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='cccccc');
}
.logo {
border: none;
margin: 5px 5px 0px 30px;
}

 

This Page Cannot Be Displayed

Authentication is required to access the Internet using this system. A valid user ID and password must be entered when prompted.

If you have questions, please contact Help Desk Team and provide the codes shown below.

Date: Tue, 05 Nov 2019 09:08:32 +0530
Username:
Source IP: xxx.xxx.xxx.14
URL: GET http://xxx.xxx.xxx.16/
Category:
Reason: UNKNOWN
Notification: PROXY_AUTH_REQUIRED

A couple of notes that are not directly related to the issue. You are running a very, very old version of Elasticsearch and should look to upgrade. You are also running two different versions in your cluster, which is bad. All nodes in a cluster should always use exactly the same version as indices created on the newer node can not be replicated or moved to the older node.

At this time, we can't proceed with to upgrade process due to limited resources and convert current indices to newer version.

The only thing is to fix this issue until we migrate the system.

The current python script work without any issue for long time. Two weeks back I got mentioned error suddenly and I tried to fix it. Unfortunately I don't have any idea to find what exact happen.

I have tried configure and run curator with configuration YML file as well

[root@server .curator]# curator --config curator.yml snapshot.yml

I got same error log for the same

2019-11-05 16:19:36,096 ERROR     Failed to complete action: snapshot.  <class 'elasticsearch.exceptions.ConnectionError'>: ConnectionError(('Connection aborted.', error(104, 'Connection reset by peer'))) caused by: ProtocolError(('Connection aborted.', error(104, 'Connection reset by peer')))

What is this elasticsearch connection exceptions ?

  • Connection aborted
  • Connection reset by peer

How do I start to trace this connection error to figure out exact issue ?

The short answer is that Curator doesn’t fully support proxies, particularly ones requiring authentication. If you were able to run Curator from somewhere that can reach the cluster without needing to go through an authenticated proxy, it should be fine.

@theuntergeek

This server does not use any proxy and the script does not configure to run through proxy

That may be. But the response you shared from trying to run curl showed that it was trying to go through a proxy.

Perhaps you need to unset some environment variables?

I have unset all proxy setting if any and restarted. But still I am getting same error !

If you restarted the computer, it probably reset the proxy settings. Trying running env and see if the HTTP_PROXY environment variables are set.

Issued env and checked whether proxy environment variables are set. Nothing set for proxies.

I’m sorry. I can’t explain what you’re seeing, then. Somehow the connection between your Curator instance and Elasticsearch is being routed through an authenticated proxy. Currently, Curator can only connect directly, or through unauthenticated proxies using environment variables. I can’t troubleshoot beyond what I’ve suggested here so far. You’ll have to involve your IT department and ask what’s going on.

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