A python implementation of an Elastic Agent Client
Project description
Python Elastic Agent client
Looking for the main Elastic Agent client (GoLang)?
This is a python implementation, and is a technical preview.
Using an example
Agent needs a binary to run. A simple executable shell script will do.
#!/bin/bash
PYTHON_PATH=/path/to/bin/python
PY_AGENT_CLIENT_PATH=/path/to/python-elastic-agent-client
$PYTHON_PATH $PY_AGENT_CLIENT_PATH/elastic_agent_client/examples/fake/component.py
Put those contents in a elastic-agent*/data/elastic-agent*/components/python-elastic-agent-client file, and
chmod 755 elastic-agent*/data/elastic-agent*/components/python-elastic-agent-client
You'll also need to create a specfile at elastic-agent*/data/elastic-agent*/components/python-elastic-agent-client.spec.yml
with the contents:
version: 2
inputs:
- name: fake-py
description: "Fake Py component input"
platforms: &platforms
- linux/amd64
- linux/arm64
- darwin/amd64
- darwin/arm64
- windows/amd64
- container/amd64
- container/arm64
outputs: &outputs
- elasticsearch
shippers: &shippers
- shipper
command: &command
restart_monitoring_period: 5s
maximum_restarts_per_period: 1
timeouts:
restart: 1s
args: []
Then use this input in your elastic-agent.yml with:
inputs:
- type: fake-py
id: fake-py
use_output: default
You can easily tail the logs by running:
sudo ./elastic-agent 2>&1 >/dev/null | jq '.message'
Developing
To get started, run:
make clean install
What's happening?
Protobuf
The proto definitions for Elastic Agent live in the GoLang implementation repo.
To avoid duplicate code, they are not checked in here.
Instead, when make generate runs, it will:
- download the raw
*.protofiles from the GoLang repo - use
grpc_tools.protocto generate python code from those specs - store that generated code in
elastic_agent_client/generated - post-process them a bit (grpc_tools generates python2 imports, instead of python3 🤷)
TODO List
- remove all inline TODOs
- write a blog
- one day...
- support "custom actions" to trigger a sync, test connection, etc
- capture diagnostic metrics. See suggested metrics
- add automation to re-generate+PR if source protos are changed. GH action on elastic-agent-client repo?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file elastic_agent_client-0.0.1.dev2.tar.gz.
File metadata
- Download URL: elastic_agent_client-0.0.1.dev2.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76d1080f3bd5dff2f495441033309ce42f4cee5830d01be0da52848ace228a1c
|
|
| MD5 |
b5ab0314782c4e46d18e3d9d8c90b04f
|
|
| BLAKE2b-256 |
6fc3dabeb3d78dc7e7e9cfd5ba070e2c823ac96e8d21d031ada9900b79525d6d
|
File details
Details for the file elastic_agent_client-0.0.1.dev2-py3-none-any.whl.
File metadata
- Download URL: elastic_agent_client-0.0.1.dev2-py3-none-any.whl
- Upload date:
- Size: 50.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d53d0e6cf415c59a27f025b7d668c3cfd5ceecf18587d8bdb7dba2740687679
|
|
| MD5 |
527e1ea72b01f58e2b3b64324cf54d16
|
|
| BLAKE2b-256 |
9b443c1fe297ebc17e876bb21f1478a22e86e95bd88eb3f9e062434c20ffabbd
|