The blackbean is a command tool for elasticsearch operations by using cobra.

Overview

Go 1.16 codecov CI Workflow Go Report Card

blackbean

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

image

Configuration

Define your config file firstly, and specify current as one of your cluster.

cluster:
  default:
    url: https://a.es.com:9200
    username: Noah
    password: abc
  backup:
    url: https://b.es.com:9200
    username: Noah
    password: abc
current: default

Shell completion

> ~/.bashrc ">
[root@noah ~]# echo "source <(blackbean completion bash)" >> ~/.bashrc
[root@noah ~]# blackbean [tab][tab]
apply       completion  current     get         help        repo        snapshot    use
[root@docker ~]# blackbean get [tab][tab]
allocations   cachemem      health        largeindices  nodes         segmem        threadpoo

Command

[root@noah ~]# blackbean [tab][tab]
apply       completion  current     get         help        repo        snapshot    use
[root@noah ~]# blackbean
blackbean command provides a set of commands to talk with es via cli.
Besides, blackbean is the name of my favorite french bulldog.

Usage:
  blackbean [command]

Available Commands:
  apply       apply cluster settings.
  completion  Generate completion script
  current     show current cluster context
  get         get allocation/nodes/health/nodes/threadpool/cache memory/segments memory/large indices.
  help        Help about any command
  repo        repo operations
  snapshot    snapshot operations
  use         change current cluster context

Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)
  -h, --help            help for blackbean
  -t, --toggle          Help message for toggle

Use "blackbean [command] --help" for more information about a command.

Use

[root@noah ~]# blackbean current
current using cluster: qa
[root@noah ~]# blackbean use [tab][tab]
prod  qa
[root@noah ~]# blackbean use qa
change to cluster: qa

Get info

[root@noah ~]# blackbean get health 
[200 OK] epoch      timestamp cluster       status node.total node.data shards  pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1624371902 14:25:02  black-cluster green          12         9   9304 4652    0    0        0             0                  -                100.0%

Put Settings

[root@noah ~]# blackbean apply settings -e
null       primaries
[root@noah ~]# blackbean apply settings -h
apply cluster settings ... wordless

Usage:
  blackbean apply [resource] [flags]

Flags:
  -e, --allocation_enable string                   to set allocation enable value, primaries or null
  -f, --breaker_fielddata string                   to set breaker_fielddata value, such as 60%
  -r, --breaker_request string                     to set breaker_request value, such as 60%
  -t, --breaker_total string                       to set breaker_total value, such as 60%
  -a, --cluster_concurrent_rebalanced string       to set cluster_concurrent_rebalanced value, such as 10
  -h, --help                                       help for apply
  -b, --max_bytes_per_sec string                   to set indices recovery max_bytes_per_sec, default 40
  -m, --max_compilations_rate string               to set max_compilations_rate value, such as 75/5m
  -s, --max_shards_per_node string                 to set max_shards_per_node value, such as 1000
  -n, --node_concurrent_recoveries string          to set node_concurrent_recoveries value, such as 10
  -i, --node_initial_primaries_recoveries string   to set node_initial_primaries_recoveries value, such as 10
  -w, --watermark_high string                      to set watermark_high value, such as 85%
  -l, --watermark_low string                       to set watermark_low value, such as 90%

Global Flags:
  -c, --cluster string   to specify a es cluster (default "default")
      --config string    config file (default is $HOME/.blackbean.yaml)

Repo

[root@noah ~]# blackbean repo
repo operations ... wordless

Usage:
  blackbean repo [command]

Available Commands:
  create      create specific snapshots
  delete      delete specific snapshots
  get         get specific repository

Flags:
  -h, --help   help for repo

Global Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)

Use "blackbean repo [command] --help" for more information about a command.

Snapshot

[root@noah ~]# blackbean snapshot
snapshot operations ... wordless

Usage:
  blackbean snapshot [command]

Available Commands:
  create      create specific snapshots
  delete      delete specific snapshots
  get         get specific snapshots
  restore     get specific index to restore

Flags:
  -h, --help   help for snapshot

Global Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)

Use "blackbean snapshot [command] --help" for more information about a command.

Index Search

[root@noah ~]# blackbean index
index operations ... wordless

Usage:
  blackbean index [command]

Available Commands:
  get         get index from cluster
  search      search index from cluster

Flags:
  -h, --help   help for index

Global Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)

Use "blackbean index [command] --help" for more information about a command.
[root@noah ~]# blackbean index search test-* -f query.json
[200 OK] {
  "took" : 172,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 16600,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
  ...
[root@noah ~]# blackbean index search test-* -f query.yaml
[200 OK] {
  "took" : 172,
  "timed_out" : false,
  ...
[root@noah ~]# blackbean index search test-* -d '{"query":{"match_all":{}}}'
[200 OK] {
  "took" : 172,
  "timed_out" : false,
  ...

Index Get

[root@noah ~]# blackbean index get test-2021.06
[200 OK] {
  "test-2021.06" : {
    "aliases" : { },
    "mappings" : {
      "dynamic_templates" : [
        {
          "strings" : {
            "match_mapping_type" : "string",
            "mapping" : {
              "type" : "keyword"
            }
    ...

Contact Me

Any advice is welcome! Please email to [email protected]

You might also like...
Prompts users to enter values for required flags in Cobra CLI applications

Cobra Flag Prompt Cobra Flag Prompt prompts users to enter values for required flags. It is an extension of Cobra, and requires that you use Cobra to

Generate an interactive, autocompleting shell for any Cobra CLI
Generate an interactive, autocompleting shell for any Cobra CLI

cobra-shell Description Leverages the Cobra completion API to generate an interactive shell for any Cobra CLI, powered by go-prompt. On-the-fly autoco

A cli client-server app with cobra
A cli client-server app with cobra

cli-client-server-calculator a cli client-server app with cobra overview this project is a cli client-server app in which client gives a bunch of numb

Cobra CLI challenge Segsalerty

Banking app done using Cobra CLI - Segsalerty challenge c/o Segun Mustafa It uses a database.json file as datastore for queries - createCustomer, Upda

This project is used to get familiar with GoLang cli apps, along with cobra generator.

SecretCTL SecretCTL About the project Status Getting started Layout Notes About the project This project is used to get familiar with GoLang cli apps,

CLI tool for CIDR range operations (check, generate)

cidrchk A CLI tool to assist you with CIDR ranges and IPs. Install it You can download the latest binary for Linux (Intel and Arm), macOS, and Windows

A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

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

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

Owner
null
command argument completion generator for spf13/cobra

Command argument completion generator for cobra. You can read more about it here: A pragmatic approach to shell completion.

null 73 Dec 26, 2022
Simple CLI using spf13/cobra and Flink REST API

Flinkctl Flinkctl is a simple CLI written on Go using Cobra created to facilitate my team's daily basis work with multiple Flink clusters at Azion Tec

Tiago Krebs 3 Aug 16, 2022
Reusable golang-migrate library using cobra utility

shift Reusable golang-migrate library using cobra utility Example Usage package main import ( "sql/db" "github.com/purwandi/shift" "github.com

purwandi 0 Dec 16, 2021
CLI to run a docker image with R. CLI built using cobra library in go.

BlueBeak Installation Guide Task 1: Building the CLI The directory structure looks like Fastest process: 1)cd into bbtools 2)cd into bbtools/bin 3)I h

Aniruddha Chattopadhyay 0 Dec 20, 2021
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

Dipto Chakrabarty 2 Jan 2, 2022
Cobra CLI tool to generate applications and commands

Cobra Generator Cobra provides its own program that will create your application and add any commands you want. It's the easiest way to incorporate Co

Steve Francia 263 Jan 3, 2023
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 usage: pipelinetester [<flags>] <p

Mario Castro 1 Oct 19, 2021
sttr is command line software that allows you to quickly run various transformation operations on the string.

sttr is command line software that allows you to quickly run various transformation operations on the string.

Abhimanyu Sharma 60 Sep 21, 2021
Build an interactive CLI application with Go, Cobra and promptui. Video tutorial available on the Div Rhino YouTube channel.

Build an interactive CLI app with Go, Cobra and promptui Text tutorial: https://divrhino.com/articles/build-interactive-cli-app-with-go-cobra-promptui

Div Rhino Dev 16 Dec 8, 2022