Splunk Search

How to modify search text with Javascript

d_o_c
New Member

I'm using Splunk Enterprise Version: 7.3.0

I'm trying to make a chrome extension that will allow me to toggle line-comments in the search window. It's tedious to prepend comment(" and append ") to each line I want to comment-out.

I've discovered that the search text is ultimately stored in "ace_line_group" classes, one ace_line_group per line of the text. These ace_line_groups reside inside a ace_text-layer.

Let's try modifying the following line:

alt text

Let's not even worry about modifying the search to any reasonable value and instead just make sure that we can in fact modify the search text at all. The closest I've gotten to doing so is the following command, which would change the first line of the query to "hello":

document.getElementsByClassName('ace_line_group')[0].innerText = "hello"

At first this appears to actually change the value of the first line of the search text. However there's a bunch of empty space after "hello."

alt text

This empty space can be copy-pasted to reveal the original text! Additionally, if the first line is then edited in the search window, as soon as a key is pressed, the line reverts back to its original state.

Is there any way I can actually modify the text in the search window with javascript?

0 Karma
Get Updates on the Splunk Community!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...