A simple CLI tool to use the _simulate API of elasticsearch to quickly test pipelines

elasticsearch-pipeline-tester

A simple CLI tool to use the _simulate API of elasticsearch to quickly test pipelines

File path of the pipeline to use [ ] The log filepath to parse. Use stdin flag if you want to work just on the cli ">
usage: pipelinetester [<flags>] <pipeline> [<logs>]

Flags:
      --help                     Show context-sensitive help (also try --help-long and --help-man).
  -e, --elasticsearch="http://localhost:9200"  
                                 URL of Elasticsearch. Scheme and port are mandatory (but HTTPS is not tested xD)
  -p, --pipeline-name="testing"  Name of the pipeline to create on elasticsearch
  -u, --ugly                     Deactivate pretty printing
  -b, --bulk                     Use bulk if you want to make a single request to ES and get a single response with many documents
  -s, --skip=0                   Skip the N first documents
  -n, --total=0                  Process a total of N documents. You can use it with skip
  -i, --stdin                    Instead of using an input log file, read from stdin

Args:
  <pipeline>  File path of the pipeline to use
  [<logs>]    The log filepath to parse. Use stdin flag if you want to work just on the cli

Example usage

$ head log/ingest/pipeline.yml                                                                              [11:16:25]
description: Pipeline for parsing Kibana logs
on_failure:
- set:
    field: error.message
    value: '{{ _ingest.on_failure_message }}'
processors:
- set:
    field: event.ingested
    value: '{{_ingest.timestamp}}'
- rename:

$ head log/test/test.log                                                                                    [11:16:37]
{"type":"response","@timestamp":"2018-05-09T10:57:55Z","tags":[],"pid":69410,"method":"get","statusCode":304,"req":{"url":"/ui/fonts/open_sans/open_sans_v15_latin_600.woff2","method":"get","headers":{"host":"localhost:5601","connection":"keep-alive","origin":"http://localhost:5601","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36","accept":"*/*","referer":"http://localhost:5601/app/kibana","accept-encoding":"gzip, deflate, br","accept-language":"en-US,en;q=0.9,de;q=0.8","if-none-match":"\"24234c1c81b3948758c1a0be8e5a65386ca94c52\"","if-modified-since":"Thu, 03 May 2018 09:45:28 GMT"},"remoteAddress":"127.0.0.1","userAgent":"127.0.0.1","referer":"http://localhost:5601/app/kibana"},"res":{"statusCode":304,"responseTime":26,"contentLength":9},"message":"GET /ui/fonts/open_sans/open_sans_v15_latin_600.woff2 304 26ms - 9.0B"}
{"type":"log","@timestamp":"2018-05-09T10:59:12Z","tags":["debug","monitoring-ui","kibana-monitoring"],"pid":69776,"message":"Fetching data from kibana_stats collector"}
{"type":"log","@timestamp":"2018-05-09T10:59:12Z","tags":["reporting","debug","exportTypes"],"pid":69776,"message":"Found exportType at /Users/ruflin/Downloads/6.3/kibana-6.3.0-darwin-x86_64/node_modules/x-pack/plugins/reporting/export_types/csv/server/index.js"}
{"type":"response","@timestamp":"2018-05-09T10:57:55Z","tags":[],"pid":69410,"method":"get","statusCode":304,"req":{"url":"/ui/fonts/open_sans/open_sans_v15_latin_600.woff2","method":"get","headers":{"host":"localhost:5601","connection":"keep-alive","origin":"http://localhost:5601","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36","accept":"*/*","referer":"http://localhost:5601/app/kibana","accept-encoding":"gzip, deflate, br","accept-language":"en-US,en;q=0.9,de;q=0.8","if-none-match":"\"24234c1c81b3948758c1a0be8e5a65386ca94c52\"","if-modified-since":"Thu, 03 May 2018 09:45:28 GMT"},"remoteAddress":"127.0.0.1","userAgent":"127.0.0.1","referer":"http://localhost:5601/app/kibana"},"res":{"statusCode":304,"responseTime":3000,"contentLength":9},"message":"GET /ui/fonts/open_sans/open_sans_v15_latin_600.woff2 304 26ms - 9.0B"}

$ pipelinetester -n 1 ~/go/src/github.com/elastic/beats/filebeat/module/kibana/log/ingest/pipeline.yml ~/go/src/github.com/elastic/beats/filebeat/module/kibana/log/test/test.log
  INFO[0000](2021-10-13T11:25:05.162856172+02:00) github.com/sayden/pipelinetester/main.go:217 Pipeline insertion output:
{
  "acknowledged": true
}

  INFO[0000](2021-10-13T11:25:05.164341632+02:00) github.com/sayden/pipelinetester/main.go:168 Response:
{sayden➜github.com/sayden/pipelinetester(main✗)» ./pipelinetester -n 1 ~/go/src/github.com/elastic/beats/filebeat/module/kibana/log/ingest/pipeline.yml ~/go/src/github.com/elastic/beats/filebeat/module/kibana/log/test/test.log                     [11:20:17]
Pipeline output:
{
  "acknowledged": true
}
  INFO[0000](2021-10-13T11:22:31.629405406+02:00) github.com/sayden/pipelinetester/main.go:168 Result:
{
  "docs": [
    {
      "doc": {
        "_id": "",
        "_index": "",
        "_ingest": {
          "timestamp": "2021-10-13T09:22:31.628472071Z"
        },
        "_source": {
          "error": {
            "message": "field [@timestamp] doesn't exist"
          },
          "event": {
            "ingested": "2021-10-13T09:22:31.628472071Z"
          },
          "message": {
            "@timestamp": "2018-05-09T10:57:55Z",
            "message": "GET /ui/fonts/open_sans/open_sans_v15_latin_600.woff2 304 26ms - 9.0B",
            "method": "get",
            "pid": 69410,
            "req": {
              "headers": {
                "accept": "*/*",
                "accept-encoding": "gzip, deflate, br",
                "accept-language": "en-US,en;q=0.9,de;q=0.8",
                "connection": "keep-alive",
                "host": "localhost:5601",
                "if-modified-since": "Thu, 03 May 2018 09:45:28 GMT",
                "if-none-match": "\"24234c1c81b3948758c1a0be8e5a65386ca94c52\"",
                "origin": "http://localhost:5601",
                "referer": "http://localhost:5601/app/kibana",
                "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"
              },
              "method": "get",
              "referer": "http://localhost:5601/app/kibana",
              "remoteAddress": "127.0.0.1",
              "url": "/ui/fonts/open_sans/open_sans_v15_latin_600.woff2",
              "userAgent": "127.0.0.1"
            },
            "res": {
              "contentLength": 9,
              "responseTime": 26,
              "statusCode": 304
            },
            "statusCode": 304,
            "tags": [],
            "type": "response"
          }
        }
      }
    }
  ]
  "docs": [
    {
      "doc": {
        "_id": "",
        "_index": "",
        "_ingest": {
          "timestamp": "2021-10-13T09:25:05.163496474Z"
        },
        "_source": {
          "error": {
            "message": "field [@timestamp] doesn't exist"
          },
          "event": {
            "ingested": "2021-10-13T09:25:05.163496474Z"
          },
          "message": {
            "@timestamp": "2018-05-09T10:57:55Z",
            "message": "GET /ui/fonts/open_sans/open_sans_v15_latin_600.woff2 304 26ms - 9.0B",
            "method": "get",
            "pid": 69410,
            "req": {
              "headers": {
                "accept": "*/*",
                "accept-encoding": "gzip, deflate, br",
                "accept-language": "en-US,en;q=0.9,de;q=0.8",
                "connection": "keep-alive",
                "host": "localhost:5601",
                "if-modified-since": "Thu, 03 May 2018 09:45:28 GMT",
                "if-none-match": "\"24234c1c81b3948758c1a0be8e5a65386ca94c52\"",
                "origin": "http://localhost:5601",
                "referer": "http://localhost:5601/app/kibana",
                "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"
              },
              "method": "get",
              "referer": "http://localhost:5601/app/kibana",
              "remoteAddress": "127.0.0.1",
              "url": "/ui/fonts/open_sans/open_sans_v15_latin_600.woff2",
              "userAgent": "127.0.0.1"
            },
            "res": {
              "contentLength": 9,
              "responseTime": 26,
              "statusCode": 304
            },
            "statusCode": 304,
            "tags": [],
            "type": "response"
          }
        }
      }
    }
  ]
}
Owner
Mario Castro
Author of "Go Design Patterns" book. Obsessive Compulsive Disorder & Insomnia Driven Developer, software engineer and maker. I love Go, Rust, Haskell and FP
Mario Castro
Similar Resources

Small CLI Tool to store test artifacts in a tamperproof way

Small CLI Tool to store test artifacts in a tamperproof way

Oct 3, 2022

Robust, flexible and resource-efficient pipelines using Go and the commandline

Robust, flexible and resource-efficient pipelines using Go and the commandline

Robust, flexible and resource-efficient pipelines using Go and the commandline Project links: Documentation & Main Website | Issue Tracker | Chat Why

Dec 25, 2022

gomerge is a tool to quickly bulk merge several pull requests from your terminal.

gomerge is a tool to quickly bulk merge several pull requests from your terminal.

Gomerge is a tool to quickly enable you to bulk merge Github pull requests from your terminal. The intention of this tool is to simplfy, and eventually automate the merging of github pull requests. This tool should be able to run on most systems.

Dec 28, 2022

textnote is a command line tool for quickly creating and managing daily plain text notes.

textnote is a command line tool for quickly creating and managing daily plain text notes. It is designed for ease of use to encourage the practice of daily, organized note taking. textnote intentionally facilitates only the management (creation, opening, organizing, and consolidated archiving) of notes, following the philosophy that notes are best written in a text editor and not via a CLI.

Jan 2, 2023

A command line tool for quickly converting Unix timestamps to human readable form.

stamp A command line tool to quickly format a Unix timestamp in a human-readable form. Installation Go is required to build this software. To just bui

Oct 30, 2021

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely.

Dec 31, 2022

Go-api-cli - Small CLI to fetch data from an API sync and async

Async API Cli CLI to fetch data on "todos" from a given API in a number of ways.

Jan 13, 2022

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Jan 12, 2022

Go-file-downloader-ftctl - A file downloader cli built using golang. Makes use of cobra for building the cli and go concurrent feature to download files.

ftctl This is a file downloader cli written in Golang which uses the concurrent feature of go to download files. The cli is built using cobra. How to

Jan 2, 2022
Buildkite-cli - Command line tool for interacting with Buildkite pipelines, builds, and more

Buildkite CLI Command line tool for interacting with Buildkite pipelines, builds

Jan 7, 2022
Esdump is a migration CLI written in Go for migrating index mapping and data from one elasticsearch to another.

esdump Introduction esdump is a migration CLI written in Go for migrating index mapping and data from one elasticsearch to another. Compatibility Elas

Jul 23, 2022
The blackbean is a command tool for elasticsearch operations by using cobra.
The blackbean is a command tool for elasticsearch operations by using cobra.

The blackbean is a command tool for elasticsearch operations by using cobra. Besides, blackbean is the name of my lovely French bulldog.

Mar 3, 2022
Bk - Command line tool for interacting with Buildkite pipelines, builds, and more

Buildkite CLI Command line tool for interacting with Buildkite pipelines, builds

Jan 7, 2022
Test-app-url-shortner - A sample url shortener app to test Keploy integration capabilities
Test-app-url-shortner - A sample url shortener app to test Keploy integration capabilities

test-app-url-shortner A sample url shortener app to test Keploy integration capa

Jan 23, 2022
Go-test-app - Test application to verify environment deployment and reachability over HTTP

Test app Test application to verify environment deployment and reachability over

May 23, 2022
A fork of k3sup that lets you quickly deploy RKE2 clusters via the CLI.

k2sup This is an awful hack of a fork of Alex Ellis' k3sup - a light-weight utility to get from zero to KUBECONFIG, originally with K3s but now with R

Dec 12, 2022
Snippet CLI manger for quickly using code snippets without leaving the terminal
Snippet CLI manger for quickly using code snippets without leaving the terminal

SnipKit - Snippet CLI manager This repository is still work in progress! SnipKit aims to paste code snippets from your favorite snippet manager into y

Dec 27, 2022
This package can parse date match expression, which used by ElasticSearch

datemath-parser this package is pure go package, this package can parse date match expression, which used by ElasticSearch. Date Math Definition you c

Jan 8, 2022
This tool is a CLI-interactive tool for TA who use eeclass platform

NTHU eeclass TA helper. This tool is a CLI-interactive tool for TA who use eeclass platform. It helps TA to download all the submitted homework, and use CSV to record the score and comment, and upload CSV score directly to the eeclass platform with just 2 Enter key!

Dec 11, 2021