Curl query to delete index patterns, and, parsefailures to stdout

Hi all...
I have 2 questions-

  1. I have created more than 150 index patterns based on the indexes I have. Yesterday I changed the names of indexes for better visibility. Now I need to delete all old index-patterns using a curl query. I can run through a loop, feeding index-patterns from a file and running curl for deleting them one by one.
    But I am not able to delete any index pattern using curl. I followed this
    But throws an error-
curl -X DELETE -u elastic:MyPassword "http://localhost:5601/api/index_patterns/index_pattern/application" -H 'kbn-xsrf: true'
{"statusCode":404,"error":"Not Found","message":"Saved object [index-pattern/application] not found"}

Any suggestions here?

Thanks alot...

[EDIT]: The index-pattern exists in kibana and I could delete it manually from browser.

  1. I have lots of json and csv files to parse (hundreds in number). For keeping a track of failures, I want to print the events of only parsefailures to stdout.
    Tried
output {
       elasticearch { hosts => "localhost"  index => "index1"  }
       if "parsefailure" in [tags] { stdout { } }
}

but it didn't work. I need to see both events of dateparsefailure and csvfarsefailure on stdout. There are no suggestions on internet about this. Also, plz note that I have atleast 3 tags with every log.

This is the request that you have to use:

$ curl -X DELETE api/saved_objects/index-pattern/my-pattern

where my-pattern is the index-pattern ID.

1 Like

Thanks @Marius_Dragomir for the reply. The curl command shows below error-

curl -X DELETE -u elastic:**** -H 'kbn-xsrf: ""' http://localhost:5601/api/saved_objects/index-patterns/security
{"statusCode":404,"error":"Not Found","message":"Saved object [index-patterns/security] not found"}

But the pattern security does exists in kibana

You have
index-patterns with an s

it should be

index-pattern without an s

1 Like

Even that threw the same error.
Anyways, I found the GUI method to delete index-patterns through saved objects option. So problem solved. I can delete around 200 patterns in one go now.
Thanks...

anyways, I found alternate method. The objective was to delete index patterns. I know that it is deviating from the original question about curl method, but not bad if it gets the job done. I was able to delete index patterns in bulk from saved objects from kibana. Just for the help if someone comes across this.

As you discovered, You do it through the Kibana API and yes that's a completely different syntax AND endpoint.

Glad you got it solved

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