<?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: Auto expand a nested list in a JSON log in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Auto-expand-a-nested-list-in-a-JSON-log/m-p/694066#M11619</link>
    <description>&lt;P&gt;Here is what I did for v9.1.5&lt;/P&gt;&lt;P&gt;Add CSS to&lt;BR /&gt;&lt;SPAN&gt;/opt/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/share/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/search_mrsparkle/exposed/build/css/bootstrap-dark.css&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/opt/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/share/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/search_mrsparkle/exposed/build/css/bootstrap-light.css&lt;/SPAN&gt;&lt;BR /&gt;------------------&lt;/P&gt;&lt;LI-CODE lang="css"&gt; /* The switch - the box around the slider*/
.autoexpand {
margin-top: 2px;
}
.autoexpandtext {
margin-right: 5px;
}
.switch {
position: relative;
display: inline-block;
width: 43px;
height: 18px;
margin-top:5px;
margin-bottom:0px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 10px;
width: 10px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: rgb(92, 192, 92);
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;In&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/dark/search.js&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/light/search.js&lt;BR /&gt;search for&amp;nbsp;"pull-right jobstatus-control-grouping" and add this text in that div element&lt;BR /&gt;&lt;BR /&gt;-----------------&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;div class="autoexpand"&amp;gt;&amp;lt;span class="autoexpandtext"&amp;gt;AutoexpandJSON&amp;lt;/span&amp;gt;&amp;lt;label class="switch"&amp;gt;&amp;lt;input type="checkbox" checked&amp;gt;&amp;lt;span class="slider round"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/label&amp;gt;&amp;lt;/div&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;------------------&lt;BR /&gt;&lt;BR /&gt;In the same search.js files&amp;nbsp;&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/dark/search.js&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/light/search.js&lt;BR /&gt;&lt;BR /&gt;add this scripts to the bottom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;------------------&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let autoExpandPropertyName='jsonAutoExpand';
let autoExpandSetting = localStorage.getItem(autoExpandPropertyName);
let observer2Added =false;
$(document).ready(function() {
if (autoExpandSetting === null)
{
localStorage.setItem(autoExpandPropertyName, '1');
autoExpandSetting = '1';
}
if(autoExpandSetting === '1')
{
function autoExpand(){
// console.log("autoExpand started");
$(".jsexpands").each(function() {
if($(this).html() == '[+]') {
$(this)[0].click();
}
})};
setTimeout(()=&amp;gt; {
console.log("Delayed");
// select the target node
var target = $(".shared-eventsviewer")[0];
console.log(target);
// create an observer instance
var observer6 = new MutationObserver(function(mutations) {
mutations.forEach((mutation) =&amp;gt; {
if (!mutation.addedNodes) return
autoExpand();
$(".events-controls-inner").click(); //does not refresh table if missing
})
});
// configuration of the observer:
var config = { attributes: false, childList: true, characterData: true, subtree:true};
// pass in the target node, as well as the observer options
observer6.observe(target, config);
}, "500");
}


function toggleAutoexpand(mutation){
const slider = document.querySelector('.slider');
if (slider === undefined ||slider === null) return;
if(observer2Added) return;
observer2Added = true;
if(autoExpandSetting === '0')
{
$(".switch")[0].childNodes[0].checked =false;
}
slider.addEventListener('click', () =&amp;gt; {
let storageValue = localStorage.getItem(autoExpandPropertyName);
if ( storageValue === '1')
localStorage.setItem(autoExpandPropertyName, '0');
else
localStorage.setItem(autoExpandPropertyName, '1');
location.reload();
});
observer2.disconnect();
};
let observer2 = new MutationObserver((mutations) =&amp;gt; {
mutations.forEach((mutation) =&amp;gt; {
if (!mutation.addedNodes) return
toggleAutoexpand(mutation);
})
})
setTimeout(()=&amp;gt; {
observer2.observe($(".shared-eventsviewer")[0], {
childList: true
, subtree: true
, attributes: false
, characterData: false
})
}, "500");
})&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;------------------&lt;BR /&gt;&lt;BR /&gt;To refresh the splunk css and js caching use link:&amp;nbsp;&lt;A class="" href="https://ls0pv-splhead-2:8000/en-GB/_bump" target="_blank" rel="noopener"&gt;https://yourinstance:8000/en-GB/_bump&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;On the next splunk update you have to repeat the process if everything remains the same.&lt;BR /&gt;I couldn't find any other way.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2024 14:21:34 GMT</pubDate>
    <dc:creator>rokxer</dc:creator>
    <dc:date>2024-07-23T14:21:34Z</dc:date>
    <item>
      <title>Auto expand a nested list in a JSON log</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Auto-expand-a-nested-list-in-a-JSON-log/m-p/432391#M7744</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;i got a nested list in a json log file, problem is to open it i have every time to expand it using the + sign.&lt;/P&gt;

&lt;P&gt;there is any way to to this automatically? i would like to show it withtin the event and not separated using spath and mvexpand&lt;/P&gt;

&lt;P&gt;Thanks guys&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 10:23:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Auto-expand-a-nested-list-in-a-JSON-log/m-p/432391#M7744</guid>
      <dc:creator>0xlc</dc:creator>
      <dc:date>2018-12-10T10:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Auto expand a nested list in a JSON log</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Auto-expand-a-nested-list-in-a-JSON-log/m-p/694066#M11619</link>
      <description>&lt;P&gt;Here is what I did for v9.1.5&lt;/P&gt;&lt;P&gt;Add CSS to&lt;BR /&gt;&lt;SPAN&gt;/opt/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/share/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/search_mrsparkle/exposed/build/css/bootstrap-dark.css&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/opt/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/share/&lt;/SPAN&gt;&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;&lt;SPAN&gt;/search_mrsparkle/exposed/build/css/bootstrap-light.css&lt;/SPAN&gt;&lt;BR /&gt;------------------&lt;/P&gt;&lt;LI-CODE lang="css"&gt; /* The switch - the box around the slider*/
.autoexpand {
margin-top: 2px;
}
.autoexpandtext {
margin-right: 5px;
}
.switch {
position: relative;
display: inline-block;
width: 43px;
height: 18px;
margin-top:5px;
margin-bottom:0px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 10px;
width: 10px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: rgb(92, 192, 92);
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;In&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/dark/search.js&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/light/search.js&lt;BR /&gt;search for&amp;nbsp;"pull-right jobstatus-control-grouping" and add this text in that div element&lt;BR /&gt;&lt;BR /&gt;-----------------&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;div class="autoexpand"&amp;gt;&amp;lt;span class="autoexpandtext"&amp;gt;AutoexpandJSON&amp;lt;/span&amp;gt;&amp;lt;label class="switch"&amp;gt;&amp;lt;input type="checkbox" checked&amp;gt;&amp;lt;span class="slider round"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/label&amp;gt;&amp;lt;/div&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;------------------&lt;BR /&gt;&lt;BR /&gt;In the same search.js files&amp;nbsp;&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/dark/search.js&lt;BR /&gt;/opt/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/share/&lt;SPAN class=""&gt;splunk&lt;/SPAN&gt;/search_mrsparkle/exposed/build/pages/light/search.js&lt;BR /&gt;&lt;BR /&gt;add this scripts to the bottom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;------------------&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let autoExpandPropertyName='jsonAutoExpand';
let autoExpandSetting = localStorage.getItem(autoExpandPropertyName);
let observer2Added =false;
$(document).ready(function() {
if (autoExpandSetting === null)
{
localStorage.setItem(autoExpandPropertyName, '1');
autoExpandSetting = '1';
}
if(autoExpandSetting === '1')
{
function autoExpand(){
// console.log("autoExpand started");
$(".jsexpands").each(function() {
if($(this).html() == '[+]') {
$(this)[0].click();
}
})};
setTimeout(()=&amp;gt; {
console.log("Delayed");
// select the target node
var target = $(".shared-eventsviewer")[0];
console.log(target);
// create an observer instance
var observer6 = new MutationObserver(function(mutations) {
mutations.forEach((mutation) =&amp;gt; {
if (!mutation.addedNodes) return
autoExpand();
$(".events-controls-inner").click(); //does not refresh table if missing
})
});
// configuration of the observer:
var config = { attributes: false, childList: true, characterData: true, subtree:true};
// pass in the target node, as well as the observer options
observer6.observe(target, config);
}, "500");
}


function toggleAutoexpand(mutation){
const slider = document.querySelector('.slider');
if (slider === undefined ||slider === null) return;
if(observer2Added) return;
observer2Added = true;
if(autoExpandSetting === '0')
{
$(".switch")[0].childNodes[0].checked =false;
}
slider.addEventListener('click', () =&amp;gt; {
let storageValue = localStorage.getItem(autoExpandPropertyName);
if ( storageValue === '1')
localStorage.setItem(autoExpandPropertyName, '0');
else
localStorage.setItem(autoExpandPropertyName, '1');
location.reload();
});
observer2.disconnect();
};
let observer2 = new MutationObserver((mutations) =&amp;gt; {
mutations.forEach((mutation) =&amp;gt; {
if (!mutation.addedNodes) return
toggleAutoexpand(mutation);
})
})
setTimeout(()=&amp;gt; {
observer2.observe($(".shared-eventsviewer")[0], {
childList: true
, subtree: true
, attributes: false
, characterData: false
})
}, "500");
})&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;------------------&lt;BR /&gt;&lt;BR /&gt;To refresh the splunk css and js caching use link:&amp;nbsp;&lt;A class="" href="https://ls0pv-splhead-2:8000/en-GB/_bump" target="_blank" rel="noopener"&gt;https://yourinstance:8000/en-GB/_bump&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;On the next splunk update you have to repeat the process if everything remains the same.&lt;BR /&gt;I couldn't find any other way.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 14:21:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Auto-expand-a-nested-list-in-a-JSON-log/m-p/694066#M11619</guid>
      <dc:creator>rokxer</dc:creator>
      <dc:date>2024-07-23T14:21:34Z</dc:date>
    </item>
  </channel>
</rss>

