From Kibana devtools to Elasticsearch


Hello everyone.

I am very new to Elasticsearch and Kibana (in fact it is the first time I know the tools), so sorry for noob questions.

I can login to my kibana website ( using my username and password, and using devtools (Console) I can put a call like:

GET nxxxx-2010.01.*/_search
  "query": {
    "match_all": {}

And it returns to around 200K results (hits": { "total": 204575,)

Now I want to perform a same search in Python 3


es = Elasticsearch ('', httpauth=('username', 'password'))

page =
          index = ' nxxxx-2010.01.*',
          scroll = '2m',
          size = 1000,
          body = {
            "query": {"match_all": {}}

and I have the error ERROR:root:TransportError(302, '')

How can I transfer the query in Console Kibana to Python code?


(Jon Budzenski) #2

is kibana or elasticsearch? It should be elasticsearch (the 302 is consistent with Kibana's root url).

The query looks fine, I'd try with some light cleanup and being explicit:

es = Elasticsearch([

index = also seems to have a leading space on the index name, i'd try removing that


Thanks for that, but now I have the error 404


Here is the full error log:

Traceback (most recent call last):
 File "", line 83, in download_job                                                              "query": {"match_all": {}}
     File "/home/username/anaconda3/lib/python3.6/site-packages/elasticsearch/client/", line 76, in _wrapped               return func(*args, params=params, **kwargs)                                                                           File "/home/username/anaconda3/lib/python3.6/site-packages/elasticsearch/client/", line 655, in search             doc_type, '_search'), params=params, body=body)                                                                       File "/home/username/anaconda3/lib/python3.6/site-packages/elasticsearch/", line 318, in perform_request          status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
                File "/home/username/anaconda3/lib/python3.6/site-packages/elasticsearch/connection/", line 185, in perform_request
                             self._raise_error(response.status, raw_data)                                                                          File "/home/username/anaconda3/lib/python3.6/site-packages/elasticsearch/connection/", line 125, in _raise_error       raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)                 elasticsearch.exceptions.NotFoundError: <unprintable NotFoundError object>
                                                                               During handling of the above exception, another exception occurred:
                                                                                      Traceback (most recent call last):
 File "/home/username/anaconda3/lib/python3.6/logging/", line 992, in emit                                          msg = self.format(record)
      File "/home/username/anaconda3/lib/python3.6/logging/", line 838, in format                                        return fmt.format(record)
      File "/home/username/anaconda3/lib/python3.6/logging/", line 575, in format                                        record.message = record.getMessage()                                                                                  File "/home/username/anaconda3/lib/python3.6/logging/", line 336, in getMessage                                    msg = str(self.msg)
            File "/home/username/anaconda3/lib/python3.6/site-packages/elasticsearch/", line 58, in __str__                  cause = ', %r' %['error']['root_cause'][0]['reason']                                                      TypeError: string indices must be integers                                                                              Call stack:
                        File "", line 187, in <module>                                                                 download_job ()
                File "", line 167, in download_job                                                             logging.error(ex)
            Message: NotFoundError(404, 'Not Found', {'statusCode': 404, 'error': 'Not Found', 'message': 'Not Found'})             Arguments: ()    

(system) #6

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