SlideShare a Scribd company logo
1
Jeff Moore
08/25/20, Systems Engineer, Bandwidth
esctl in Action
or How I Built a CLI tool
to Interact with
Elasticsearch
2
About this presentation
It was fairly difficult deciding between catering towards Devs or Ops. In the
end, I decided to side with the Ops side of the house. Based on audience
request, I will go into the code in depth - or that can be the topic of a later talk.
Feel free to stop me at any point* so we can discuss this utility - however,
suggestions are encouraged to be held until the end of the slide deck
3
Contributors Welcome!
https://github.com/geoffmore/esctl
4
Hopeful Takeaways
- An extensible CLI tool that may impact both
yourself and your Org
- Lessons learned from over a year of
becoming a stronger Golang developer
5
Caveats
- This is not complete.
- Work has been focused on getting good boilerplate
- Not all endpoints have been implemented (templates, indices, etc)
- This is not intended to replace the SDKs
6
Why esctl?
Devs have a lot of SDKs, but Ops doesn’t
appear to have anything
77
We needed an easier way to
interact with Elasticsearch as
operators of the cluster
8
Intent of esctl
1. Standard endpoints are mocked, with basic config options exposed as
flags
2. Extra commands are added based on functions that could be necessary
(i.e admin, util)
99
Inspiration
10
11
12
escli and esctl
A brief history of two cli tools
13
escli vs esctl
Comparison of metrics
Metric escli esctl
Language Bash Golang
Function implementation Bash functions Subcommands
# of commands (Aug
2020)
117 44
New functions Easy to add Tedious
Extensibility Difficult Easy
Refactorability Difficult Not as difficult
Barrier to entry Easy Difficult
14
Getting Started Demo
Overview of Demo
Environment
1 2 3 4
Overview of local
cluster init script
Overview of
Kubernetes
manifests
Demo of
commands and
features
15
Homelab Architecture
16
17
On Command Structure
- Elasticsearch api structure is very different to that of Kubernetes
- Format in v0.1.4 is esctl <endpoint/resource> <function>
- Format in Kubectl is kubectl <function> <endpoint/resource>
18
Command Structure Comparison pt. 1
kubectl vs. esctl - Similarities
CLI Tool Command Function Resource
kubectl kubectl get nodes Get Nodes
esctl esctl cat nodes Get Nodes
19
Command Structure Comparison pt. 2
kubectl vs. esctl - Differences
CLI Tool Command Function Resource
kubectl kubectl get ns Get Namespaces
esctl esctl index get Get Indices
(Yes, I am comparing namespaces to
shards. Feel free to discuss offline)
20
Command Structure Comparison pt. 3
kubectl vs. esctl - the Justification
The endpoint behind commands like
esctl cat nodes is /_cat/nodes. By
mocking functions after their API
syntax, there is no mental translation
tax needed to move to/from esctl and
the REST API
21
Proudly Built on go-elasticsearch SDK
Elasticsearch SDK, mostly written by Karel Minarik from Elastic
Defines api endpoint options as struct fields
Allows client initialization
Located at https://github.com/elastic/go-elasticsearch
22
23
esctl Extensibility Examples - Showing Inactive Watchers
Problem: Watchers not currently active (read: disabled) need to be listed
Solution:
- Get all watchers (SearchRequest on .watches index)
- Filter to desired activity state
- Return output (esutil helper function)
24
esctl Extensibility Examples - Getting Search Metrics
Problem: User queries need to be validated before a DeleteByQuery is run
Solution:
• Take a query
• Merge a known aggregation definition to that query
• Execute that query (SearchRequest)
• Return output (esutil helper function)
25
esctl Extensibility Examples - Removing Empty Indices
Problem: Empty indices created by ILM policies cause disk utilization
inbalances
Solution:
- Get a list of all indices (IndicesGetRequest)
- Filter to indices containing 0 documents
- Delete those indices (IndicesDeleteRequest)
2626
Still Not Sold?
esctl api <HTTP verb> endpoint
27
Lessons Learned
- Writing a CLI tool isn’t easy
- Design should come before writing code to avoid a large number of
refactors
- Reading documentation thoroughly before using imported code is
extremely valuable
- This CLI tool continues to be a great learning opportunity for me
28
Overall, building this CLI tool was
a painful experience; but, if it was
painless, I would be a Java dev
instead of a Golang dev
Me, just now
29
Future Improvements
- Add documentation
- Discuss command structure
- Need a logo
- Codegen?
30
What I Need from YOU!
- Use it
- File bugs and RFEs
3131
Questions?
3232
https://www.linkedin.com/in/jeff-moore-k8s
https://github.com/geoffmore
Reach Out!
3333
Thanks!

More Related Content

PPTX
Apache Airflow Introduction
PDF
An intro to Kubernetes operators
PDF
Helm - Application deployment management for Kubernetes
PDF
Angular 2 observables
PPTX
State in stateless serverless functions
PPTX
Nova Update - OpenStack Ops Midcycle, Manchester, Feb 2016
PPTX
Kubeflow on google kubernetes engine
PPTX
Сергей Калинец "Не SQL-ом единым..."
Apache Airflow Introduction
An intro to Kubernetes operators
Helm - Application deployment management for Kubernetes
Angular 2 observables
State in stateless serverless functions
Nova Update - OpenStack Ops Midcycle, Manchester, Feb 2016
Kubeflow on google kubernetes engine
Сергей Калинец "Не SQL-ом единым..."

What's hot (20)

PPTX
What's new in c# 8.0
PDF
PuppetConf 2017: Kubernetes in the Cloud w/ Puppet + Google Container Engine-...
PPTX
Nova Updates - Kilo Edition
PDF
Operator SDK for K8s using Go
PDF
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
PDF
OpenStack reliability metrics
PPTX
OpenStack Nova Liberty Update
PDF
Intro to os-faults library
PPTX
Игорь Фесенко "Direction of C# as a High-Performance Language"
PPTX
Aks: k8s e azure
PDF
PPTX
Nautilus
PPTX
What is the OpenStack Platform? By Peter Dens - Kangaroot
PDF
Crunchy containers
PDF
Handling Kubernetes Resources
PDF
Kubeflow control plane
PDF
Serverless with Knative - Mete Atamel (Google)
PDF
Dynamic infrastructure for development
PDF
From airflow to google cloud composer
PDF
Sprint 43 Review
What's new in c# 8.0
PuppetConf 2017: Kubernetes in the Cloud w/ Puppet + Google Container Engine-...
Nova Updates - Kilo Edition
Operator SDK for K8s using Go
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
OpenStack reliability metrics
OpenStack Nova Liberty Update
Intro to os-faults library
Игорь Фесенко "Direction of C# as a High-Performance Language"
Aks: k8s e azure
Nautilus
What is the OpenStack Platform? By Peter Dens - Kangaroot
Crunchy containers
Handling Kubernetes Resources
Kubeflow control plane
Serverless with Knative - Mete Atamel (Google)
Dynamic infrastructure for development
From airflow to google cloud composer
Sprint 43 Review
Ad

Similar to Esctl in action elastic user group presentation aug 25 2020 (20)

PDF
ELK-Stack-Essential-Concepts-TheELKStack-LunchandLearn.pdf
PDF
Null Bachaav - May 07 Attack Monitoring workshop.
PPTX
Attack monitoring using ElasticSearch Logstash and Kibana
PPTX
The ELK Stack - Launch and Learn presentation
PPT
How ElasticSearch lives in my DevOps life
PDF
Elk stack @inbot
PDF
Elasticsearch in Netflix
PDF
2015 03-16-elk at-bsides
PDF
Elasticsearch
PDF
Logs aggregation and analysis
PPTX
Intro elasticsearch taswarbhatti
PDF
ElasticSearch Introduction
PDF
Log analysis with the elk stack
PDF
ELK stack introduction
PDF
Elasticsearch Introduction at BigData meetup
PDF
Setting ELK in 10 minutes on Windows locally
PDF
Elasticsearch, a distributed search engine with real-time analytics
PPT
Elk presentation1#3
PPTX
06 integrate elasticsearch
PPTX
ELK-Stack-Grid-KA-School.pptx
ELK-Stack-Essential-Concepts-TheELKStack-LunchandLearn.pdf
Null Bachaav - May 07 Attack Monitoring workshop.
Attack monitoring using ElasticSearch Logstash and Kibana
The ELK Stack - Launch and Learn presentation
How ElasticSearch lives in my DevOps life
Elk stack @inbot
Elasticsearch in Netflix
2015 03-16-elk at-bsides
Elasticsearch
Logs aggregation and analysis
Intro elasticsearch taswarbhatti
ElasticSearch Introduction
Log analysis with the elk stack
ELK stack introduction
Elasticsearch Introduction at BigData meetup
Setting ELK in 10 minutes on Windows locally
Elasticsearch, a distributed search engine with real-time analytics
Elk presentation1#3
06 integrate elasticsearch
ELK-Stack-Grid-KA-School.pptx
Ad

More from FaithWestdorp (18)

PDF
Using Elastiknn for exact and approximate nearest neighbor search
PDF
Observability from the Home
PDF
Elasticsearch Goes to Congress
PPTX
Eliminate your zombie technology ray myers - 11-5-2020
PDF
Mejorando las busquedas en nuestras aplicaciones web con elasticsearch
PDF
Evolving with Elastic: GetSet Learning
PPTX
EmPOW: Integrating Attack Behavior Intelligence into Logstash Plugins
PDF
Examining OpenData with a Search Index using Elasticsearch
PDF
From the trenches: scaling a large log management deployment
PDF
Logstash and Maxmind: not just for GEOIP anymore
PDF
Elasticsearch's aggregations &amp; esctl in action or how i built a cli tool...
PPTX
Searching for NLP: Using Elasticsearch to Create MVPs of NLP-enabled User Ex...
PDF
Introduction to machine learning using Elastic
PDF
Upgrade your attack model: finding and stopping fileless attacks with MITRE A...
PDF
Elastic Observability
PDF
Threat hunting with Elastic APM
PDF
Guide to Data Visualization in Kibana
PDF
Elastic's recommendation on keeping services up and running with real-time vi...
Using Elastiknn for exact and approximate nearest neighbor search
Observability from the Home
Elasticsearch Goes to Congress
Eliminate your zombie technology ray myers - 11-5-2020
Mejorando las busquedas en nuestras aplicaciones web con elasticsearch
Evolving with Elastic: GetSet Learning
EmPOW: Integrating Attack Behavior Intelligence into Logstash Plugins
Examining OpenData with a Search Index using Elasticsearch
From the trenches: scaling a large log management deployment
Logstash and Maxmind: not just for GEOIP anymore
Elasticsearch's aggregations &amp; esctl in action or how i built a cli tool...
Searching for NLP: Using Elasticsearch to Create MVPs of NLP-enabled User Ex...
Introduction to machine learning using Elastic
Upgrade your attack model: finding and stopping fileless attacks with MITRE A...
Elastic Observability
Threat hunting with Elastic APM
Guide to Data Visualization in Kibana
Elastic's recommendation on keeping services up and running with real-time vi...

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Esctl in action elastic user group presentation aug 25 2020

  • 1. 1 Jeff Moore 08/25/20, Systems Engineer, Bandwidth esctl in Action or How I Built a CLI tool to Interact with Elasticsearch
  • 2. 2 About this presentation It was fairly difficult deciding between catering towards Devs or Ops. In the end, I decided to side with the Ops side of the house. Based on audience request, I will go into the code in depth - or that can be the topic of a later talk. Feel free to stop me at any point* so we can discuss this utility - however, suggestions are encouraged to be held until the end of the slide deck
  • 4. 4 Hopeful Takeaways - An extensible CLI tool that may impact both yourself and your Org - Lessons learned from over a year of becoming a stronger Golang developer
  • 5. 5 Caveats - This is not complete. - Work has been focused on getting good boilerplate - Not all endpoints have been implemented (templates, indices, etc) - This is not intended to replace the SDKs
  • 6. 6 Why esctl? Devs have a lot of SDKs, but Ops doesn’t appear to have anything
  • 7. 77 We needed an easier way to interact with Elasticsearch as operators of the cluster
  • 8. 8 Intent of esctl 1. Standard endpoints are mocked, with basic config options exposed as flags 2. Extra commands are added based on functions that could be necessary (i.e admin, util)
  • 10. 10
  • 11. 11
  • 12. 12 escli and esctl A brief history of two cli tools
  • 13. 13 escli vs esctl Comparison of metrics Metric escli esctl Language Bash Golang Function implementation Bash functions Subcommands # of commands (Aug 2020) 117 44 New functions Easy to add Tedious Extensibility Difficult Easy Refactorability Difficult Not as difficult Barrier to entry Easy Difficult
  • 14. 14 Getting Started Demo Overview of Demo Environment 1 2 3 4 Overview of local cluster init script Overview of Kubernetes manifests Demo of commands and features
  • 16. 16
  • 17. 17 On Command Structure - Elasticsearch api structure is very different to that of Kubernetes - Format in v0.1.4 is esctl <endpoint/resource> <function> - Format in Kubectl is kubectl <function> <endpoint/resource>
  • 18. 18 Command Structure Comparison pt. 1 kubectl vs. esctl - Similarities CLI Tool Command Function Resource kubectl kubectl get nodes Get Nodes esctl esctl cat nodes Get Nodes
  • 19. 19 Command Structure Comparison pt. 2 kubectl vs. esctl - Differences CLI Tool Command Function Resource kubectl kubectl get ns Get Namespaces esctl esctl index get Get Indices (Yes, I am comparing namespaces to shards. Feel free to discuss offline)
  • 20. 20 Command Structure Comparison pt. 3 kubectl vs. esctl - the Justification The endpoint behind commands like esctl cat nodes is /_cat/nodes. By mocking functions after their API syntax, there is no mental translation tax needed to move to/from esctl and the REST API
  • 21. 21 Proudly Built on go-elasticsearch SDK Elasticsearch SDK, mostly written by Karel Minarik from Elastic Defines api endpoint options as struct fields Allows client initialization Located at https://github.com/elastic/go-elasticsearch
  • 22. 22
  • 23. 23 esctl Extensibility Examples - Showing Inactive Watchers Problem: Watchers not currently active (read: disabled) need to be listed Solution: - Get all watchers (SearchRequest on .watches index) - Filter to desired activity state - Return output (esutil helper function)
  • 24. 24 esctl Extensibility Examples - Getting Search Metrics Problem: User queries need to be validated before a DeleteByQuery is run Solution: • Take a query • Merge a known aggregation definition to that query • Execute that query (SearchRequest) • Return output (esutil helper function)
  • 25. 25 esctl Extensibility Examples - Removing Empty Indices Problem: Empty indices created by ILM policies cause disk utilization inbalances Solution: - Get a list of all indices (IndicesGetRequest) - Filter to indices containing 0 documents - Delete those indices (IndicesDeleteRequest)
  • 26. 2626 Still Not Sold? esctl api <HTTP verb> endpoint
  • 27. 27 Lessons Learned - Writing a CLI tool isn’t easy - Design should come before writing code to avoid a large number of refactors - Reading documentation thoroughly before using imported code is extremely valuable - This CLI tool continues to be a great learning opportunity for me
  • 28. 28 Overall, building this CLI tool was a painful experience; but, if it was painless, I would be a Java dev instead of a Golang dev Me, just now
  • 29. 29 Future Improvements - Add documentation - Discuss command structure - Need a logo - Codegen?
  • 30. 30 What I Need from YOU! - Use it - File bugs and RFEs