<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zeeshan Zaidi</title>
    <description>The latest articles on DEV Community by Zeeshan Zaidi (@zeeshanzaidi).</description>
    <link>https://dev.to/zeeshanzaidi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F765171%2Fccb6f09f-7546-469e-a14d-e1d1468ce686.jpeg</url>
      <title>DEV Community: Zeeshan Zaidi</title>
      <link>https://dev.to/zeeshanzaidi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zeeshanzaidi"/>
    <language>en</language>
    <item>
      <title>Delete elasticsearch index without Delete Index API over the TLS while using x-pack security</title>
      <dc:creator>Zeeshan Zaidi</dc:creator>
      <pubDate>Tue, 30 Nov 2021 14:36:32 +0000</pubDate>
      <link>https://dev.to/zeeshanzaidi/delete-elasticsearch-index-without-delete-index-api-over-the-tls-while-using-x-pack-security-3ma0</link>
      <guid>https://dev.to/zeeshanzaidi/delete-elasticsearch-index-without-delete-index-api-over-the-tls-while-using-x-pack-security-3ma0</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

DAYSAGO=$(date --date="1 day ago" +%Y%m%d)

https://localhost:9200/_cat/indices?v | grep 'filebeat'`
ALLLINES=`/usr/bin/curl -s -XGET -u 'elastic:Elastic@123' https://localhost:9200/_cat/indices?v | grep 'filebeat'`

echo
echo "This is what to be delete for ELK!!! You can not recover this one gone"
echo

echo "$ALLLINES" | while read LINE
do
#  FORMATEDLINE=`echo $LINE | awk '{ print $3 }' | awk -F'-' '{ print $4 }' | sed 's/\.//g' ` 
  FORMATEDLINE=`echo $LINE | awk '{ print $3 }' | awk -F'-' '{ print $(NF) }' | sed 's/\.//g' `
  if [[ "$FORMATEDLINE" -lt "$DAYSAGO" ]]
  then
    TODELETE=`echo $LINE | awk '{ print $3 }'`
    echo "https://localhost:9200/$TODELETE"
  fi
done

echo
echo -n "if this make sence, Y to continue N to exit [Y/N]:"
read INPUT
if [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ] || [ "$INPUT" == "yes" ] || [ "$INPUT" == "YES" ]
then
  echo "$ALLLINES" | while read LINE
  do
     FORMATEDLINE=`echo $LINE | awk '{ print $3 }' | awk -F'-' '{ print $(NF) }' | sed 's/\.//g' `
    if [[ "$FORMATEDLINE" -lt "$DAYSAGO" ]]
    then
      TODELETE=`echo $LINE | awk '{ print $3 }'`
      /usr/bin/curl -XDELETE -u 'elastic:Elastic@123' localhost:9200/$TODELETE
      sleep 1
      fi
  done
else 
  echo SCRIPT CLOSED BY USER, BYE ...
  echo
  exit
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
