Splunk Search

Can we disable the inspect link from the search results ??

rakesh_498115
Motivator

Hi.

In my form search query yieds 0 results . i am getting the message " No results found " folowed by inspect link . i dnt want the users to click or see the inspect link..How can i do it ?? or is ter any way to display the custom messages..without the inspect link ??

Developers perspective i think inspect link is helpful.but for users i dnt wanna give a chance to click on the inspect link .

Thnx

Tags (1)
1 Solution

skawasaki_splun
Splunk Employee
Splunk Employee

In Splunk 6, the easiest way is

$(".alert-info:contains('No results found.')").parents('.dashboard-cell').hide()

A harder, but more complete way, is to control it individually per search/panel:

var MyView = mvc.Components.get('the_id_of_my_event');
var MyResults = MyView.data('results', {count: 1});

MyResults.on('data', function() {
    var data = this.data();

    if(data.rows.length <= 0) {
        MyView.$el.parents('.dashboard-cell').hide();
    }
});

View solution in original post

yoho
Contributor

With Splunk 6, there's even a simpler way to make it because it's a built-in feature of simple XML. Read this documentation.

the_wolverine
Champion
  • 20 because I wanted to do this per view!
0 Karma

skawasaki_splun
Splunk Employee
Splunk Employee

In Splunk 6, the easiest way is

$(".alert-info:contains('No results found.')").parents('.dashboard-cell').hide()

A harder, but more complete way, is to control it individually per search/panel:

var MyView = mvc.Components.get('the_id_of_my_event');
var MyResults = MyView.data('results', {count: 1});

MyResults.on('data', function() {
    var data = this.data();

    if(data.rows.length <= 0) {
        MyView.$el.parents('.dashboard-cell').hide();
    }
});

justgrumpy
Path Finder

For some reason I am a little leery of using ajaxComplete() it seems a little unfocused. It gets triggered for a lot of reasons that may have nothing to do with empty results.

I just figured out how to solve the problem with Sideview custom behaviors. The below example is triggered with a customBehavior param on a Table module:

 Sideview.utils.declareCustomBehavior ("checkForResults", function(tableModule) {
    tableModule.onResultsRendered = function() {
      var search = this.getContext().get('search');
      if (search.job.getResultCount() == 0) {
        this.container.find('p.emptyResults').html('no results were found');
      }
    }
  });

When the Table module is finished rendering the table "content" it calls onResultsRendered. I can then check to see if there were any results and update the emptyResults paragraph if there were none.

kmattern
Builder

Edit lines 148 and 154 in Splunk\Python-2.7\Lib\site-packages\splunk\appserver\mrsparkle\controllers\module.py and remove the matching pyo file. And restart Splunk.

Here are the edits starting at 143

        if msg == 'nodata':
            if entity_name == 'events':
                submsg = _('No matching events found.')
            else:
change this -->         # submsg = _('No results found.')
to this -->               submsg = _('Nothing to report')

            # the inspect line belo was originally _('Inspect ...')
            output += '%s <span class="resultStatusHelp"><a href="#" onclick=%s class="resultStatusHelpLink">%s</a></span>' % (
                submsg,
                su.quoteattr("Splunk.window.openJobInspector('%s');return false;" % sid.replace("'", "")),

Change this line     # _('Inspect...')
To this                _('.')
            )

The last edit leqaves a clickable dot (we call it the "Magic Dot".) We know it's there but the customer does not. The first edit simply gives a friendlier response when there are no results.

skawasaki_splun
Splunk Employee
Splunk Employee

This is highly unsupported and the changes will most likely be lost whenever you upgrade Splunk.

0 Karma

jjdorn
Explorer

The first sugguestion to hide it via the application.css file did work for hiding the inspection link application wide when a search came up empty.

jonuwz
Influencer

On a user role basis, that might be tricky.
I dont know if there's a 'default.js' that you can add to, or whether you can query what roles a user belongs to from within it - Other replies with suggestions on how to do this will be interesting.

On a per application level, there's a few options:

1) hide the link with css (add this to application.css)

.resultStatusHelpLink {
    display: none;
}

2) Hide it with js ( add this to application.js ).

$(document).ajaxComplete( function() {
    $('p.empty_results').css('display', 'none');
});

3) change the text with js

$(document).ajaxComplete( function() {
    $('p.empty_results').html('Ho Ho Ho. No results for you naughty children');
});

yoho
Contributor

Javascript is also executed on the client-side. You can selectively disable only this part of the javascript with firebug or even with the default firefox developer tools.

0 Karma

jonuwz
Influencer

The 3rd option obliterates the link. You could bypass that by disabling JavaScript, but if you did that I doubt splunkweb would function at all.

0 Karma

yoho
Contributor

Good but it's just hidden on the client side... what if your user is your customer and you don't want him to find this possibility at all ? Any way to remove the link completely ?

0 Karma

jonuwz
Influencer

Did any of these work out ?

0 Karma

jonuwz
Influencer

Its all jquery. Plenty of documentation for all the functions on jquery.com

rakesh_498115
Motivator

Thanks jonuwz..where can i found documentation for these functions ..

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...