Skip to content

"HTTPError: Not Found for url" while index pattern refresh for Kibana #100

@fabrei

Description

@fabrei

As @mmguero pointed out at this kibana issue, I tried your python script for refreshing my index pattern. But at the second request it fails in my case for kibana v.7.4.2:

GET_INDEX_PATTERN_INFO_URI = 'api/saved_objects/index-pattern'
# get the ID of the index name (probably will be the same as the name)
getIndexInfoResponse = requests.get('{}/{}/{}'.format(args.url, GET_INDEX_PATTERN_INFO_URI, args.index))
getIndexInfoResponse.raise_for_status()
getIndexInfo = getIndexInfoResponse.json()
indexId = getIndexInfo['id']

This throws a HTTPError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:5601/api/saved_objects/index-pattern/<my-index-pattern-name> The kibana docs suggest that you have to pass the id of an index pattern. So the uri GET_INDEX_PATTERN_INFO_URI does not exist.

I replaced it with the a _find api call:

GET_INDEX_PATTERN_INFO_URI = 'api/saved_objects/_find'
# get the ID of the index name (probably will be the same as the name)                                                                                                                                      
getIndexInfoResponse = requests.get(                                                                                                                                                                        
    '{}/{}'.format(args.url, GET_INDEX_PATTERN_INFO_URI),                                                                                                                                                   
        params={                                                                                                                                                                                                
            'type': 'index-pattern',                                                                                                                                                                            
            'fields': 'id',                                                                                                                                                                                     
            'search': args.index                                                                                                                                                                                
        }
)
getIndexInfoResponse.raise_for_status()
getIndexInfo = getIndexInfoResponse.json() 
indexId = getIndexInfo['saved_objects'][0]['id'] 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions