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

**URL:** <https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110>\
**Category:** Kibana\
**Created:** [July 31, 2021, 5:47am UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110 "2021-07-31T05:47:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kriss332](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kriss332/32/90137_2.png) [@kriss332](https://discuss.elastic.co/u/kriss332)\
**Post date:** [July 31, 2021, 5:47am UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/1 "2021-07-31T05:47:03Z")

</div>

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](https://www.elastic.co/guide/en/kibana/7.x/index-patterns-api-delete.html)  
But throws an error-

```auto
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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [August 3, 2021, 6:48pm UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/2 "2021-08-03T18:48:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kriss332](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kriss332/32/90137_2.png) [@kriss332](https://discuss.elastic.co/u/kriss332)\
**Post date:** [August 5, 2021, 3:54am UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/3 "2021-08-05T03:54:32Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [August 5, 2021, 5:18am UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/4 "2021-08-05T05:18:49Z")

</div>

> [@kriss332](#):
>
> `curl -X DELETE -u elastic: **** -H 'kbn-xsrf: ""' http://localhost:5601/api/saved_objects/index-patterns/security`

You have  
`index-patterns` with an `s`

it should be

`index-pattern` without an `s`

---

<div class="post-metadata">

**Author:** ![kriss332](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kriss332/32/90137_2.png) [@kriss332](https://discuss.elastic.co/u/kriss332)\
**Post date:** [August 10, 2021, 4:29pm UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/5 "2021-08-10T16:29:15Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![kriss332](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kriss332/32/90137_2.png) [@kriss332](https://discuss.elastic.co/u/kriss332)\
**Post date:** [September 5, 2021, 5:31pm UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/6 "2021-09-05T17:31:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 5, 2021, 6:35pm UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/7 "2021-09-05T18:35:38Z")

</div>

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

> **[Index patterns APIs | Kibana Guide \[7.14\] | Elastic](https://www.elastic.co/guide/en/kibana/current/index-patterns-api.html)**

Glad you got it solved

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 3, 2021, 6:36pm UTC](https://discuss.elastic.co/t/curl-query-to-delete-index-patterns-and-parsefailures-to-stdout/280110/8 "2021-10-03T18:36:05Z")

</div>

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