Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clickandmortar/kibana-url-builder

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickandmortar/kibana-url-builder

Kibana URL builder

  • 0.7.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
538
decreased by-7.88%
Maintainers
1
Weekly downloads
 
Created
Source

Kibana URL builder

This library allows building Kibana URLs, for instance when sending notifications.

:warning: Generated Kibana URLs have currently been tested on Kibana 6.x only.

Usage

# Using npm
npm install @clickandmortar/kibana-url-builder

# Using Yarn
yarn add @clickandmortar/kibana-url-builder
const kub = require('@clickandmortar/kibana-url-builder')

const url = kub.buildDiscoverUrl({
    host: 'http://kibana:5601',
    columns: ['_source'],
    filters: [],
    query: 'my query'
})

// url = http://kibana:5601/app/kibana#/discover?_g=(time:(from:now-15m,mode:quick,to:now))&_a=(columns:!(_source),filters:!(),interval:auto,query:(language:lucene,query:'my query'),sort:!('@timestamp',desc))

Methods

buildDiscoverUrl ({ host, refreshInterval, period, columns, filters, index, interval, query, sort }: KibanaDiscoverUrlBuildParameters): string

This method returns a stateless Kibana "Discover" URL, which can be shared and used by anyone having access to the Kibana instance.

ParameterTypeDefaultRequiredExample
hoststringhttp://kibana:5601
columnsstring[]['_source']['_source', 'log']
filtersKibanaQueryFilter[][]See below
querystringfoo AND bar (Lucene syntax)
periodKibanaQueryPeriod{ "from": "now-15m", "mode": "quick", "to": "now" }See below
indexstringWhen using filtersmy-index-pattern
intervalstringauto15m
refreshIntervalKibanaQueryRefreshInterval{ "pause": true, "value": 300000 }
sortKibanaQuerySort{ "field": "@timestamp", "direction": "desc" }
Filters

When using filters, you must provide the index pattern name using index property.

Supported filter types:

  • Exists / Not exists (type = exists)
  • Is / Is not (type = query)
  • One of / Not one of (type = phrases)
  • Between / Not between (type = range)

"Not" filters can be used setting the negate property of the filter to true.

All filters are of type KibanaQueryFilter and share the following properties:

PropertyTypeDefaultRequiredDescription
typestring-See below examples
fieldstring-Name of the ES field
valuestring|boolean|number|string[]-See below examples
negatebooleanfalse-Negate the filter
aliasstringnoneAlias for the filter
disabledbooleanfalseMark filter as disabled
Exists / Not exists
{
  type: 'exists',
  field: 'statusCode'
}
Is / Is not
{
  type: 'query',
  field: 'namespace',
  value: 'kube-system'
}
One of / Not one of
{
  type: 'phrases',
  field: 'namespace',
  value: ['kube-system', 'default']
}
Between / Not between
{
  type: 'range',
  field: 'statusCode',
  value: [400, 499]
}
Period

Three period presets are available:

  • quick and relative: dates using Elasticsearch Date Math, ie. now, now-7d, etc.
  • absolute: absolute dates
Quick & Relative periods
{
  from: 'now-7d',
  to: 'now',
  mode: 'quick'
}
Absolute periods
{
  from: '2021-03-31T22:00:00.000Z',
  to: '2021-04-02T21:59:59.999Z',
  mode: 'absolute'
}

Testing

npm run test

Enhancements

  • Add support for filters
  • Add tests: ⚙️ WIP
  • Add missing filters: is one of, is between
  • Add documentation for filters
  • Add documentation for advanced period
  • Add support for Visualize query

Keywords

FAQs

Package last updated on 08 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc