guilhemmarchand / nmon-for-splunk

NMON For Splunk App - convert, index and exploit nmon metrics data for AIX, Solaris and Linux Systems
23 stars 13 forks source link

Feature request: allow deactivation for auto-refresh feature #103

Closed guilhemmarchand closed 7 years ago

guilhemmarchand commented 7 years ago

Add following macro code:

########################################
# auto-refresh
########################################

# This macro is being used for the auto-refresh feature within the various dashboards
# By default, the macro checks if the time range selected is a past search, or a search accros incoming data

# If this is a past search, it sets the following:

# For past searches: (auto deactivation of the auto-refresh form)
# is_past_search="true"

# For non past data: (auto activation of the auto-refresh form)
# is_past_search="false"

# If for customization purposes, you want the auto-refresh to be deactivated by default, create a local/macros.conf containing the following version:

# [auto_refresh]
# definition = | stats c | eval is_past_search="true" | fields is_past_search
# iseval = 0

[auto_refresh]
definition = | stats c | addinfo | eval now=now(), delta_now=now-info_max_time, is_past_search=if(delta_now>=14400, "true", "false") | fields is_past_search
iseval = 0

Update dashboard with:

<!-- autorefresh_detection -->

    <search id="autorefresh_detection">
        <query>`auto_refresh`</query>
        <earliest>$timerange.earliest$</earliest>
        <latest>$timerange.latest$</latest>
        <progress>
            <condition match="'result.is_past_search'==&quot;true&quot;">
                <set token="form.refresh">0</set>
            </condition>
            <condition match="'result.is_past_search'==&quot;false&quot;">
                <unset token="form.refresh"></unset>
            </condition>
        </progress>
    </search>