<?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 [Solution] Splunk HEC and iOS/HomeKit Shortcuts in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Solution-Splunk-HEC-and-iOS-HomeKit-Shortcuts/m-p/612965#M106053</link>
    <description>&lt;P&gt;&lt;FONT size="6"&gt;&lt;STRONG&gt;Splunk HEC and iOS/HomeKit Shortcuts&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;A number of years ago the PM for HEC happen to sit behind me at a conf keynote. Glenn leaned forward and said you’re going to love this. He was right, I fell in love with HEC right away.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Few months later I was giving him grief about where the HEC example code was for Python because the RaspberryPi universal forward was not getting love at the time. He replied it’s just JSON and Post just write it. So I did and made a HEC python class a number of folks still use. (&lt;A href="https://github.com/georgestarcher/Splunk-Class-httpevent" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;GitHub - georgestarcher/Splunk-Class-httpevent: Python class to submit events to Splunk HTTP Event Collector&lt;/SPAN&gt;&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;Recently, I was messing with a lot of iOS shortcuts (&lt;A href="https://support.apple.com/guide/shortcuts/welcome/ios" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://support.apple.com/guide/shortcuts/welcome/ios&lt;/SPAN&gt;&lt;/A&gt;) automating things on my phone and my home. I wondered what if I posted JSON to the SplunkTrust (&lt;A href="https://www.splunk.com/en_us/community/splunk-trust.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://www.splunk.com/en_us/community/splunk-trust.html &lt;/SPAN&gt;&lt;/A&gt;) SpunkCloud instance. Could I do it easily and natively within shortcuts?&lt;/P&gt;
&lt;P&gt;The short answer is &lt;SPAN&gt;&lt;STRONG&gt;&lt;I&gt;YES&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;!&lt;/P&gt;
&lt;P&gt;You need to remember HEC was made by devs for devs. So you need only to decide a good JSON (Dictionary) payload that meets the HEC Events endpoint formatting. We bother with the raw endpoint because the Dictionary object is a native shortcuts thing.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You will need a valid HEC receiver setup which is beyond the scope of this post.&lt;/LI&gt;
&lt;LI&gt;The HEC receiver will have to be reachable from the Internet such as SplunkCloud.&lt;/LI&gt;
&lt;LI&gt;You will need to have a valid HEC token and know the index. Here we just use main.&lt;/LI&gt;
&lt;LI&gt;You will have to look at the attached screen shots. I am not typing out every tap and step here. Shortcuts are visually self explanatory.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;IOS Shortcuts&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Shortcuts have more power on iOS vs on HomeKit. So first we will cover the easy way on iOS.&lt;/P&gt;
&lt;P&gt;First you will want to make a new shortcut to act at your HEC Sender. This is so you can set it up once but run it from other shortcuts that have a well formed JSON event to send. Think python class/code reuse.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_0-1663106863374.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21450i859390C392EC2221/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_0-1663106863374.jpeg" alt="starcher_0-1663106863374.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_1-1663106863375.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21449iA3FAA3FBECC950CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_1-1663106863375.jpeg" alt="starcher_1-1663106863375.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;We receive text from input to the shortcut. This is what we receive when this shortcut is called by “Run Shortcut”&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;We store that in a variable “Hec Payload”&lt;/LI&gt;
&lt;LI&gt;We next store the Full URL to the Hec Events endpoint and the Hec Token in variables&lt;/LI&gt;
&lt;LI&gt;The finally trick is doing the POST action of the payload to the HEC receiver using the “Get contents of HTTP” Action. Note in the attached screen shot we change the action to post, set the header and use type of File for the JSON payload.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Next let’s setup a shortcut that sends the data we want.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Here we make one to get the device name, other device information and log the battery level at the time.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_2-1663106863376.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21451i18B150C2BE0B4D6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_2-1663106863376.jpeg" alt="starcher_2-1663106863376.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The key is making the Dictionary object for the HEC event payload.&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;Here is a drill down of that section.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_3-1663106863376.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21454i6F2436039D02E43E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_3-1663106863376.jpeg" alt="starcher_3-1663106863376.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Last we automate the running of the data shortcut whenever we plug our device into power.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_4-1663106863377.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21453i5332F060C65C2A1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_4-1663106863377.jpeg" alt="starcher_4-1663106863377.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_5-1663106863378.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21452i3FA5D81C92F3DC0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_5-1663106863378.jpeg" alt="starcher_5-1663106863378.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To show it works like a champ:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_6-1663106863378.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21455iF5E927502824F205/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_6-1663106863378.jpeg" alt="starcher_6-1663106863378.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_7-1663106863378.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21457iF5AA194DFC8A0241/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_7-1663106863378.jpeg" alt="starcher_7-1663106863378.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;HomeKit&lt;/STRONG&gt;&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;Now let’s say you want to log an event from a light coming on. HomeKit can execute some limited shortcut actions. These get executed on whatever your HomeKit hub turns out to be hence the limitation Such as an AppleTV 4K or HomePod. The limitation for us is there is no Run Shortcut action.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This means you have to make the JSON payload (dictionary) object and the HTTP action together in each automation. No easy setup the HEC send and call it as needed&lt;/P&gt;
&lt;P&gt;In this example we simply log when my mantle hue bulb comes on. This could be anything HomeKit can trigger off of such as a button press, motion, temperature etc. I won’t expand it all as they work the same way as our previous example. This just shows you have to build the payload and post action inside each HomeKit automation action.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_8-1663106863379.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21456iF9F1AF07D1E431D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_8-1663106863379.jpeg" alt="starcher_8-1663106863379.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_9-1663106863380.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21458i11DED9DA35A70570/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_9-1663106863380.jpeg" alt="starcher_9-1663106863380.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;What is next&lt;/STRONG&gt;?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Well you can automate HEC post of any data that an iOS or HomeKit shortcut can see. Use your imagination for data that is of value to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Sep 2022 23:47:22 GMT</pubDate>
    <dc:creator>starcher</dc:creator>
    <dc:date>2022-09-13T23:47:22Z</dc:date>
    <item>
      <title>[Solution] Splunk HEC and iOS/HomeKit Shortcuts</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Solution-Splunk-HEC-and-iOS-HomeKit-Shortcuts/m-p/612965#M106053</link>
      <description>&lt;P&gt;&lt;FONT size="6"&gt;&lt;STRONG&gt;Splunk HEC and iOS/HomeKit Shortcuts&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;A number of years ago the PM for HEC happen to sit behind me at a conf keynote. Glenn leaned forward and said you’re going to love this. He was right, I fell in love with HEC right away.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Few months later I was giving him grief about where the HEC example code was for Python because the RaspberryPi universal forward was not getting love at the time. He replied it’s just JSON and Post just write it. So I did and made a HEC python class a number of folks still use. (&lt;A href="https://github.com/georgestarcher/Splunk-Class-httpevent" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;GitHub - georgestarcher/Splunk-Class-httpevent: Python class to submit events to Splunk HTTP Event Collector&lt;/SPAN&gt;&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;Recently, I was messing with a lot of iOS shortcuts (&lt;A href="https://support.apple.com/guide/shortcuts/welcome/ios" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://support.apple.com/guide/shortcuts/welcome/ios&lt;/SPAN&gt;&lt;/A&gt;) automating things on my phone and my home. I wondered what if I posted JSON to the SplunkTrust (&lt;A href="https://www.splunk.com/en_us/community/splunk-trust.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://www.splunk.com/en_us/community/splunk-trust.html &lt;/SPAN&gt;&lt;/A&gt;) SpunkCloud instance. Could I do it easily and natively within shortcuts?&lt;/P&gt;
&lt;P&gt;The short answer is &lt;SPAN&gt;&lt;STRONG&gt;&lt;I&gt;YES&lt;/I&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;!&lt;/P&gt;
&lt;P&gt;You need to remember HEC was made by devs for devs. So you need only to decide a good JSON (Dictionary) payload that meets the HEC Events endpoint formatting. We bother with the raw endpoint because the Dictionary object is a native shortcuts thing.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You will need a valid HEC receiver setup which is beyond the scope of this post.&lt;/LI&gt;
&lt;LI&gt;The HEC receiver will have to be reachable from the Internet such as SplunkCloud.&lt;/LI&gt;
&lt;LI&gt;You will need to have a valid HEC token and know the index. Here we just use main.&lt;/LI&gt;
&lt;LI&gt;You will have to look at the attached screen shots. I am not typing out every tap and step here. Shortcuts are visually self explanatory.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;IOS Shortcuts&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Shortcuts have more power on iOS vs on HomeKit. So first we will cover the easy way on iOS.&lt;/P&gt;
&lt;P&gt;First you will want to make a new shortcut to act at your HEC Sender. This is so you can set it up once but run it from other shortcuts that have a well formed JSON event to send. Think python class/code reuse.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_0-1663106863374.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21450i859390C392EC2221/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_0-1663106863374.jpeg" alt="starcher_0-1663106863374.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_1-1663106863375.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21449iA3FAA3FBECC950CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_1-1663106863375.jpeg" alt="starcher_1-1663106863375.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;We receive text from input to the shortcut. This is what we receive when this shortcut is called by “Run Shortcut”&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;We store that in a variable “Hec Payload”&lt;/LI&gt;
&lt;LI&gt;We next store the Full URL to the Hec Events endpoint and the Hec Token in variables&lt;/LI&gt;
&lt;LI&gt;The finally trick is doing the POST action of the payload to the HEC receiver using the “Get contents of HTTP” Action. Note in the attached screen shot we change the action to post, set the header and use type of File for the JSON payload.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Next let’s setup a shortcut that sends the data we want.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Here we make one to get the device name, other device information and log the battery level at the time.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_2-1663106863376.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21451i18B150C2BE0B4D6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_2-1663106863376.jpeg" alt="starcher_2-1663106863376.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The key is making the Dictionary object for the HEC event payload.&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;Here is a drill down of that section.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_3-1663106863376.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21454i6F2436039D02E43E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_3-1663106863376.jpeg" alt="starcher_3-1663106863376.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Last we automate the running of the data shortcut whenever we plug our device into power.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_4-1663106863377.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21453i5332F060C65C2A1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_4-1663106863377.jpeg" alt="starcher_4-1663106863377.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_5-1663106863378.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21452i3FA5D81C92F3DC0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_5-1663106863378.jpeg" alt="starcher_5-1663106863378.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To show it works like a champ:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_6-1663106863378.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21455iF5E927502824F205/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_6-1663106863378.jpeg" alt="starcher_6-1663106863378.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_7-1663106863378.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21457iF5AA194DFC8A0241/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_7-1663106863378.jpeg" alt="starcher_7-1663106863378.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;HomeKit&lt;/STRONG&gt;&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;Now let’s say you want to log an event from a light coming on. HomeKit can execute some limited shortcut actions. These get executed on whatever your HomeKit hub turns out to be hence the limitation Such as an AppleTV 4K or HomePod. The limitation for us is there is no Run Shortcut action.&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This means you have to make the JSON payload (dictionary) object and the HTTP action together in each automation. No easy setup the HEC send and call it as needed&lt;/P&gt;
&lt;P&gt;In this example we simply log when my mantle hue bulb comes on. This could be anything HomeKit can trigger off of such as a button press, motion, temperature etc. I won’t expand it all as they work the same way as our previous example. This just shows you have to build the payload and post action inside each HomeKit automation action.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_8-1663106863379.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21456iF9F1AF07D1E431D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_8-1663106863379.jpeg" alt="starcher_8-1663106863379.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="starcher_9-1663106863380.jpeg" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/21458i11DED9DA35A70570/image-size/medium?v=v2&amp;amp;px=400" role="button" title="starcher_9-1663106863380.jpeg" alt="starcher_9-1663106863380.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;STRONG&gt;What is next&lt;/STRONG&gt;?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Well you can automate HEC post of any data that an iOS or HomeKit shortcut can see. Use your imagination for data that is of value to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 23:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Solution-Splunk-HEC-and-iOS-HomeKit-Shortcuts/m-p/612965#M106053</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2022-09-13T23:47:22Z</dc:date>
    </item>
  </channel>
</rss>

