<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to delete ITSI entities automatically ? in Splunk ITSI</title>
    <link>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485239#M1860</link>
    <description>&lt;P&gt;Likely irrelevant to the OP after all this time, but relevant to anyone trying to figure out the same thing.  &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;I would like to preface this with perform the below at your own risk.  You should always test and vet through any intrusive process in a production environment before executing. At a minimum take a full backup from the UI just in case, and also export all of your entity information.&lt;/STRONG&gt;  You can create a table with all of your entity information(JSON for the whole entity, and broken out entity title, name and all info fields) by performing the following:&lt;/P&gt;

&lt;P&gt;| rest splunk_server=local /servicesNS/nobody/SA-ITOA/itoa_interface/entity&lt;BR /&gt;
fields="_key,title,identifier,informational,identifying_name" report_as=text&lt;BR /&gt;
| eval value=spath(value,"{}")&lt;BR /&gt;
| mvexpand value&lt;BR /&gt;
| eval entity_title=spath(value, "title"),&lt;BR /&gt;
entity_name=spath(value, "identifying_name"),&lt;BR /&gt;
entity_aliases=mvzip(spath(value, "identifier.fields{}"),spath(value, "identifier.values{}"),"="),&lt;BR /&gt;
entity_info=mvzip(spath(value, "informational.fields{}"),spath(value, "informational.values{}"),"="), _key=spath(value, "_key")&lt;BR /&gt;
|  rename entity_info as _raw&lt;BR /&gt;
|  kv&lt;BR /&gt;
|  rename entity_aliases as _raw&lt;BR /&gt;
|  kv&lt;BR /&gt;
|  fields - _raw&lt;BR /&gt;
|  fillnull value=NOTSET&lt;/P&gt;

&lt;P&gt;Export as CSV and tuck away.  I'm not sure if the entity info is stored anywhere in the local OS for the SH, but this got me what I needed for other things.  &lt;/P&gt;

&lt;P&gt;After a couple of years of muddling through ITSI configurations, and numerous upgrades, trying to figure out what worked for us,  we needed to delete all entities to reconfigure them in a uniform way.  The online documentation only goes so far in explaining the process for non-developer minded folks like myself.  I am right now deleting all of my entities in an automatic way for preparation to re-import from our inventory systems.  Below is what I did:&lt;/P&gt;

&lt;P&gt;You first need to pull a list of all _key values for your entities.  Run this from splunk search:&lt;/P&gt;

&lt;P&gt;| rest splunk_server=local /servicesNS/nobody/SA-ITOA/itoa_interface/entity&lt;BR /&gt;
fields="_key,title,identifier,informational,identifying_name" report_as=text&lt;BR /&gt;
| eval value=spath(value,"{}")&lt;BR /&gt;
| mvexpand value&lt;BR /&gt;
| eval entity_title=spath(value, "title"),&lt;BR /&gt;
entity_name=spath(value, "identifying_name"),&lt;BR /&gt;
entity_aliases=mvzip(spath(value, "identifier.fields{}"),spath(value, "identifier.values{}"),"="),&lt;BR /&gt;
entity_info=mvzip(spath(value, "informational.fields{}"),spath(value, "informational.values{}"),"="), _key=spath(value, "_key")&lt;BR /&gt;
|  table _key&lt;/P&gt;

&lt;P&gt;Export the table as CSV. When mine I ran it didn't actually display the table but the results were there.  I think some visual bug.  &lt;/P&gt;

&lt;P&gt;Because of how splunk exports everything, there is a \r at the end of each row data.  Copy the CSV contents into notepad++, or other text editor.  Do a replace all command finding \r and replacing with nothing.  Transfer the modified text file over to a machine with access to the ITSI API.  &lt;/P&gt;

&lt;P&gt;From there, you can run the following bash for i loop command.  Note the use of the variable in the curl command is why you had to go through the find and replace above. &lt;/P&gt;

&lt;P&gt;for i in $(cat itsi_delete.txt); do curl -X DELETE -k -u  username:password https://:8089/servicesNS/nobody/SA-ITOA/itoa_interface/entity/$i; done&lt;/P&gt;

&lt;P&gt;Looks like it takes about 1-5 seconds per entity.  We are down to around 13.6k entities, from 16.2k. entities, after about 1hr. &lt;/P&gt;

&lt;P&gt;Other items of note from the environment I ran this in:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Currently running ITSI 4.4.3&lt;/LI&gt;
&lt;LI&gt;Currently Running Splunk 8.0&lt;/LI&gt;
&lt;LI&gt;9 search heads in the SHC. &lt;/LI&gt;
&lt;LI&gt;16,231 configured entities at start&lt;/LI&gt;
&lt;LI&gt;37 distinct informational fields intermixed across the entity population&lt;/LI&gt;
&lt;LI&gt;We had no base searches, correlation searches, or services running that are doing entity filtering.&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;95% of what my ITSI deployment does is the running of 250+ correlation searches and 190+ aggregation policies.  We built a custom integration using the ITSI SDK that receives a custom alert action from the ITSI aggregation policy, and then retrieves the full JSON results for the episode for integration to our internal ticketing system.&lt;BR /&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:17:28 GMT</pubDate>
    <dc:creator>cdemir</dc:creator>
    <dc:date>2020-09-30T05:17:28Z</dc:date>
    <item>
      <title>How to delete ITSI entities automatically ?</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485237#M1858</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;Since the ITSI entities import in CSV through search-based results has a setting only for upsert or append. &lt;BR /&gt;
How to delete/remove itsi entities which we won't get/don't see in the search that we initially used to import? &lt;BR /&gt;
If someone has achieved it please let me know ho to do it. &lt;/P&gt;

&lt;P&gt;Example: &lt;BR /&gt;
&lt;EM&gt;Kubernetes cluster nodes imported as entities. But as you are aware that cluster nodes can scale up/down dynamically so we need to remove the entities(cluster nodes) that doesn't exist anymore.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 20:47:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485237#M1858</guid>
      <dc:creator>sreedharmallemp</dc:creator>
      <dc:date>2019-09-23T20:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete ITSI entities automatically ?</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485238#M1859</link>
      <description>&lt;P&gt;Hi, unfortunately there's currently no way to automatically delete entities. However, you can follow the entity bulk delete steps here to get rid of some: &lt;A href="https://docs.splunk.com/Documentation/ITSI/4.3.1/Configure/Deleteentities"&gt;https://docs.splunk.com/Documentation/ITSI/4.3.1/Configure/Deleteentities&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 20:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485238#M1859</guid>
      <dc:creator>esnyder_splunk</dc:creator>
      <dc:date>2019-10-21T20:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete ITSI entities automatically ?</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485239#M1860</link>
      <description>&lt;P&gt;Likely irrelevant to the OP after all this time, but relevant to anyone trying to figure out the same thing.  &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;I would like to preface this with perform the below at your own risk.  You should always test and vet through any intrusive process in a production environment before executing. At a minimum take a full backup from the UI just in case, and also export all of your entity information.&lt;/STRONG&gt;  You can create a table with all of your entity information(JSON for the whole entity, and broken out entity title, name and all info fields) by performing the following:&lt;/P&gt;

&lt;P&gt;| rest splunk_server=local /servicesNS/nobody/SA-ITOA/itoa_interface/entity&lt;BR /&gt;
fields="_key,title,identifier,informational,identifying_name" report_as=text&lt;BR /&gt;
| eval value=spath(value,"{}")&lt;BR /&gt;
| mvexpand value&lt;BR /&gt;
| eval entity_title=spath(value, "title"),&lt;BR /&gt;
entity_name=spath(value, "identifying_name"),&lt;BR /&gt;
entity_aliases=mvzip(spath(value, "identifier.fields{}"),spath(value, "identifier.values{}"),"="),&lt;BR /&gt;
entity_info=mvzip(spath(value, "informational.fields{}"),spath(value, "informational.values{}"),"="), _key=spath(value, "_key")&lt;BR /&gt;
|  rename entity_info as _raw&lt;BR /&gt;
|  kv&lt;BR /&gt;
|  rename entity_aliases as _raw&lt;BR /&gt;
|  kv&lt;BR /&gt;
|  fields - _raw&lt;BR /&gt;
|  fillnull value=NOTSET&lt;/P&gt;

&lt;P&gt;Export as CSV and tuck away.  I'm not sure if the entity info is stored anywhere in the local OS for the SH, but this got me what I needed for other things.  &lt;/P&gt;

&lt;P&gt;After a couple of years of muddling through ITSI configurations, and numerous upgrades, trying to figure out what worked for us,  we needed to delete all entities to reconfigure them in a uniform way.  The online documentation only goes so far in explaining the process for non-developer minded folks like myself.  I am right now deleting all of my entities in an automatic way for preparation to re-import from our inventory systems.  Below is what I did:&lt;/P&gt;

&lt;P&gt;You first need to pull a list of all _key values for your entities.  Run this from splunk search:&lt;/P&gt;

&lt;P&gt;| rest splunk_server=local /servicesNS/nobody/SA-ITOA/itoa_interface/entity&lt;BR /&gt;
fields="_key,title,identifier,informational,identifying_name" report_as=text&lt;BR /&gt;
| eval value=spath(value,"{}")&lt;BR /&gt;
| mvexpand value&lt;BR /&gt;
| eval entity_title=spath(value, "title"),&lt;BR /&gt;
entity_name=spath(value, "identifying_name"),&lt;BR /&gt;
entity_aliases=mvzip(spath(value, "identifier.fields{}"),spath(value, "identifier.values{}"),"="),&lt;BR /&gt;
entity_info=mvzip(spath(value, "informational.fields{}"),spath(value, "informational.values{}"),"="), _key=spath(value, "_key")&lt;BR /&gt;
|  table _key&lt;/P&gt;

&lt;P&gt;Export the table as CSV. When mine I ran it didn't actually display the table but the results were there.  I think some visual bug.  &lt;/P&gt;

&lt;P&gt;Because of how splunk exports everything, there is a \r at the end of each row data.  Copy the CSV contents into notepad++, or other text editor.  Do a replace all command finding \r and replacing with nothing.  Transfer the modified text file over to a machine with access to the ITSI API.  &lt;/P&gt;

&lt;P&gt;From there, you can run the following bash for i loop command.  Note the use of the variable in the curl command is why you had to go through the find and replace above. &lt;/P&gt;

&lt;P&gt;for i in $(cat itsi_delete.txt); do curl -X DELETE -k -u  username:password https://:8089/servicesNS/nobody/SA-ITOA/itoa_interface/entity/$i; done&lt;/P&gt;

&lt;P&gt;Looks like it takes about 1-5 seconds per entity.  We are down to around 13.6k entities, from 16.2k. entities, after about 1hr. &lt;/P&gt;

&lt;P&gt;Other items of note from the environment I ran this in:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Currently running ITSI 4.4.3&lt;/LI&gt;
&lt;LI&gt;Currently Running Splunk 8.0&lt;/LI&gt;
&lt;LI&gt;9 search heads in the SHC. &lt;/LI&gt;
&lt;LI&gt;16,231 configured entities at start&lt;/LI&gt;
&lt;LI&gt;37 distinct informational fields intermixed across the entity population&lt;/LI&gt;
&lt;LI&gt;We had no base searches, correlation searches, or services running that are doing entity filtering.&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;95% of what my ITSI deployment does is the running of 250+ correlation searches and 190+ aggregation policies.  We built a custom integration using the ITSI SDK that receives a custom alert action from the ITSI aggregation policy, and then retrieves the full JSON results for the episode for integration to our internal ticketing system.&lt;BR /&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/485239#M1860</guid>
      <dc:creator>cdemir</dc:creator>
      <dc:date>2020-09-30T05:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete ITSI entities automatically ?</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/611735#M2561</link>
      <description>&lt;P&gt;1. Generate a list of entities you want to delete,&amp;nbsp; only table the entity_key field. here I provide a example to delete retired entities.&lt;/P&gt;&lt;DIV class=""&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;DIV class=""&gt;| inputlookup itsi_entities&lt;/DIV&gt;&lt;DIV class=""&gt;| eval identical_alias = _itsi_identifier_lookups&lt;/DIV&gt;&lt;DIV class=""&gt;| mvexpand&amp;nbsp;"identical_alias"&lt;/DIV&gt;&lt;DIV class=""&gt;| eval entity_key=_key&lt;/DIV&gt;&lt;DIV class=""&gt;| where retired=1&lt;/DIV&gt;&lt;DIV class=""&gt;| dedup&amp;nbsp; entity_key&lt;/DIV&gt;&lt;DIV class=""&gt;| table entity_key&lt;/DIV&gt;&lt;DIV class=""&gt;| outputcsv entities_to_be_deleted.csv&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;if you have SHC environment, go to&lt;STRONG&gt; help --&amp;gt; about&lt;/STRONG&gt; to check which search head node you are on.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;2. ssh to that search head node&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;3. vi /opt/splunk/delete_entities.sh&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;4. paste following bash script&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;DIV class=""&gt;#! /bin/bash&lt;/DIV&gt;&lt;DIV class=""&gt;#title&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :delete_entity.sh&lt;/DIV&gt;&lt;DIV class=""&gt;#description&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :This script will delete entities showing in entities_to_be_deleted.csv. Note, this operation is not reversible".&lt;/DIV&gt;&lt;DIV class=""&gt;#author&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :WL&lt;/DIV&gt;&lt;DIV class=""&gt;#==============================================================================&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;start_time=`date&amp;nbsp;+%s.%N`&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;# copy csv file from default location of outputcsv command to local directory&lt;/DIV&gt;&lt;DIV class=""&gt;cp&amp;nbsp;/opt/splunk/var/run/splunk/csv/entities_to_be_deleted.csv&amp;nbsp;/opt/splunk&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;counter = 0&lt;/DIV&gt;&lt;DIV class=""&gt;while&amp;nbsp;IFS=","&amp;nbsp;read&amp;nbsp;-r entity_key&lt;/DIV&gt;&lt;DIV class=""&gt;do&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;echo&amp;nbsp;"removing entity $entity_key"&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;counter=`expr&amp;nbsp;$counter + 1`&lt;/DIV&gt;&lt;DIV class=""&gt;# remove csv column headers and " quotation marks while loading file&lt;/DIV&gt;&lt;DIV class=""&gt;done&amp;nbsp;&amp;lt; &amp;lt;(sed&amp;nbsp;'s/"//g'&amp;nbsp;entities_to_be_deleted.csv |&amp;nbsp;tail&amp;nbsp;-n +2)&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;# in curl command suppose to use API token for better security, for now you can swap with your credential in -u username:password format&lt;/DIV&gt;&lt;DIV class=""&gt;curl -k -u &lt;STRONG&gt;username:password&lt;/STRONG&gt; &lt;A href="https://localhost:8089/servicesNS/nobody/SA-ITOA/itoa_interface/entity/$entity_key" target="_blank" rel="noopener"&gt;https://localhost:8089/servicesNS/nobody/SA-ITOA/itoa_interface/entity/$entity_key&lt;/A&gt; -X DELETE;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;end_time=`date&amp;nbsp;+%s.%N`&lt;/DIV&gt;&lt;DIV class=""&gt;runtime=$(&amp;nbsp;echo&amp;nbsp;"$end_time - $start_time"&amp;nbsp;|&amp;nbsp;bc&amp;nbsp;-l )&lt;/DIV&gt;&lt;DIV class=""&gt;# added a reporting at the end&lt;/DIV&gt;&lt;DIV class=""&gt;echo&amp;nbsp;"script finished in $runtime seconds, $counter entities have been deleted"&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Swap username:password with your credentials&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;execute this script will delete the entities in the csv file, this way is faster than above method, because it does not need to re-authenticate every time.&lt;/DIV&gt;</description>
      <pubDate>Fri, 02 Sep 2022 10:33:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/How-to-delete-ITSI-entities-automatically/m-p/611735#M2561</guid>
      <dc:creator>liuweiwell</dc:creator>
      <dc:date>2022-09-02T10:33:49Z</dc:date>
    </item>
  </channel>
</rss>

