How to quickly start a full Elastic Stack by using elastic-package

elastic-integrations.png

In this getting starting guide you will learn how elastic-package can help you quickly start a full Elastic Stack.

Elastic-package is an open source tool that will help you shorten your development time by providing pre-built commands. For example it will help you lint, format, test, build, and promote your packages.

Each and every developer that wants to contribute by creating their own integrations should use elastic-package. It will provide a ready-to-code environment.

Getting started with elastic-package

As a developer you can use elastic-package in two ways, the first one is through binary usage and the second one is by pulling elastic-package github repository.

For binary usage, start by downloading the latest version.

Pull the archive that you need and unarchive it locally.

julienlind@MacBook-Pro Downloads % tar -xvf elastic-package_0.20.1_darwin_amd64.tar.gz

Then you can experiment with the elastic-package command line. First, try starting with the "help" command.

(Note:It might improve your developer experience if you put the tool in your PATH. Edit your ~/.bashrc file and specify your executable PATH: “PATH=$PATH:$PATH_TO_MY_EXEC”)

julienlind@MacBook-Pro Downloads % elastic-package help
elastic-package - Command line tool for developing Elastic Integrations

Usage:
  elastic-package [command]

Available Commands:
  build       Build the package
  check       Check the package
  clean       Clean used resources
  completion  generate the autocompletion script for the specified shell
  create      Create package resources
  export      Export package assets
  format      Format the package
  help        Help about any command
  install     Install the package
  lint        Lint the package
  profiles    Manage stack config profiles
  promote     Promote packages
  publish     Publish the package to the Package Registry
  service     Manage the service stack
  stack       Manage the Elastic stack
  status      Show package status
  test        Run test suite for the package
  uninstall   Uninstall the package
  version     Show application version

Flags:
  -h, --help      help for elastic-package
  -v, --verbose   verbose mode

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

With the github repository:

julienlind@MacBook-Pro Downloads % git clone https://github.com/elastic/elastic-package.git

Cloning into 'elastic-package'...
remote: Enumerating objects: 5188, done.
remote: Counting objects: 100% (1356/1356), done.
remote: Compressing objects: 100% (449/449), done.
remote: Total 5188 (delta 1078), reused 936 (delta 901), pack-reused 3832
Receiving objects: 100% (5188/5188), 13.41 MiB | 26.11 MiB/s, done.
Resolving deltas: 100% (2952/2952), done.
julienlind@MacBook-Pro Downloads % cd elastic-package
julienlind@MacBook-Pro elastic-package % make build
[...]
julienlind@MacBook-Pro elastic-package % elastic-package help

"make build”" command will call "go get" which will result in creating a binary file in ~/go/bin .

Thus here we assume that in your ~/.bashrc file you have specified your Golang executable path such as follow:

PATH=$PATH:$GOPATH/bin

Start a local elastic stack in a few minutes

Here, we assume that you do have Docker desktop up and running on your computer.

Once you do, simply use the “stack” command as in the example below:

julienlind@MacBook-Pro elastic-package % elastic-package stack up

When booting up a stack you will then be able to access all components locally and experiment with all available functionalities. If you encounter any problems add the -v option to allow verbose output. (Please note that having a low memory threshold can cause some issues with Docker settings.)

"-d" can also be used in order to run this in daemon mode.

Your local stack is now available with the following information:

Package Registry: http://localhost:8080
Elasticsearch: http://localhost:9200
Fleet Server: http://localhost:8220
kibana: http://localhost:5601
login: elastic
pass: changeme

When you are done with your tests, be sure to run a "stack down" command to shut down everything.

julienlind@MacBook-Pro elastic-package % elastic-package stack down

"Stack up" and "stack down" seem to be simple commands, but behind the scenes there are a lot of things happening. These commands start or close a set of dependent containers: elasticsearch, kibana, fleet, elastic agent and the package registry.

All those containers are deployed inside the same Docker network in order to communicate between each other.

Running "docker ps" command will help you discover what is running:

julienlind@MacBook-Pro elastic-package % docker ps
CONTAINER ID   IMAGE                                                            COMMAND                  CREATED              STATUS                        PORTS                                NAMES
1d92499e5f7b   docker.elastic.co/beats/elastic-agent-complete:7.15.0-SNAPSHOT   "/usr/bin/tini -- /u…"   About a minute ago   Up About a minute (healthy)                                        elastic-package-stack_elastic-agent_1
743bea1f53de   docker.elastic.co/beats/elastic-agent-complete:7.15.0-SNAPSHOT   "/usr/bin/tini -- /u…"   2 minutes ago        Up About a minute (healthy)   127.0.0.1:8220->8220/tcp             elastic-package-stack_fleet-server_1
0f1205be9e12   docker.elastic.co/kibana/kibana:7.15.0-SNAPSHOT                  "/bin/tini -- /usr/l…"   2 minutes ago        Up About a minute (healthy)   127.0.0.1:5601->5601/tcp             elastic-package-stack_kibana_1
56525b050da9   elastic-package-stack_package-registry                           "./package-registry …"   2 minutes ago        Up About a minute (healthy)   127.0.0.1:8080->8080/tcp             elastic-package-stack_package-registry_1
b3587459cedc   docker.elastic.co/elasticsearch/elasticsearch:7.15.0-SNAPSHOT    "/bin/tini -- /usr/l…"   2 minutes ago        Up About a minute (healthy)   127.0.0.1:9200->9200/tcp, 9300/tcp   elastic-package-stack_elasticsearch_1

Now that you are familiar with elastic-package, you can think about developing your own integrations, and testing them locally, or on your elastic stack.