Skip to main content
Version: 1.1.0

elasticquery

The command elasticquery queries time-series data in Elasticsearch with a DSL query saved in ElasticSPL. elasticquery allows the usage of complex and long queries without having huge search statements. Furthermore, the usage of saved queries allows sharing of queries with other users and allows for access restrictions.

Arguments

argumentrequiredformatdescription
instanceyesstringelastic instance used by the query
search_nameyesstringname of the saved query
timestamp_fieldnostringfield in Elasticsearch results containing the events timestamp
timestamp_usednobooleandefines if the time given in the Splunk Search is used for the query
replacementsnostringkv-pairs used to replace tokens in query
max_resultsnointthe maximal count of events fetched from Elasticsearch, defaults to unlimited. scroll_size if max_results < scroll_size
scroll_sizenointscroll size used for fetching data from Elasticsearch, can be adapted if facing performance problems

A saved DSL query defines default values for timestamp_field, timestamp_used, timestamp_format, and replacements`. As long as the user does not provide the argument, the value stored with the query is used. In case of replacements, the KV-pairs are merged. The user-provided input takes precedence if there is a definition for a key in the user's input and the saved arguments.

Examples

Query index kibana_sample_data_logs with default values

Default FieldDefault Value
timestamp_fieldtimestamp
timestamp_usedfalse
replacements

Query index kibana_sample_data_logs with timestamp_used="True"

Default FieldDefault Value
timestamp_fieldtimestamp
timestamp_usedfalse
replacements

Query index kibana_sample_data_logs with defined replacements to select a specific IP address

Default FieldDefault Value
timestamp_fieldtimestamp
timestamp_usedfalse
replacements

Query index kibana_sample_data_logs with defined replacements to select a specific IP address and timestamp_used="True"

Default FieldDefault Value
timestamp_fieldtimestamp
timestamp_usedfalse
replacements

Query index kibana_sample_data_logs conflicting replacements

Default FieldDefault Value
timestamp_fieldtimestamp
timestamp_usedfalse
replacements$ip$=199.233.207.139

Permissions

Each query is assigned to at least one role. In addition to capability checks on the operations list, run, and crud on a query, the assigned roles are checked. Users interacting with a query have to have at least one role in common.

List

The capability list_elastic_query is required to be able to view any queries. This capability is by default enabled for the role elastic_query_list. The app checks for overlap in roles while loading queries and only show relevant queries to the user.

Run

The capability run_elastic_query is required to run any query. This capability is by default enabled for the role elastic_query_run. As a user needs to be able to list queries to run them, the role imports elastic_query_list.

At the execution of a query, the app checks if the user and query have any roles in common. The execution stops, and an error message appears if there is no overlap in roles. Additionaly, the command checks if the current user is allowed to run any queries against the provided instance.

CRUD

The capability edit_elastic_query is required to perform any CRUD action. This capability is by default enabled for the role elastic_query_edit. The role elastic_query_edit imports both elastic_query_run and elastic_query_list.