Labels and Variables
Maand smartly generates variables for workers based on labels and attributes.
These variables generated to simplify service discovery, labels-based configuration, and worker-specific customizations.
Example workers.json file
[
{
"host": "10.27.221.181",
"labels": ["prometheus"]
},
{
"host": "10.27.221.144"
},
{
"host": "10.27.221.170"
}
]
based on example workers.json file, following variables are generated
Variables
WORKER_0
,WORKER_1
,WORKER_2
: IP addresses of all workers in the worker label.WORKER_INDEX
: The index of the current agent in theworker
role.WORKER_IP
: The IP address of the current worker.WORKER_WORKERS_LENGTH
: Total number of workers in theworker
labels.WORKER_WORKERS
: Comma-separated list of all worker IPs in theworker
labels.WORKER_PEERS
: Comma-separated list of all otherworker
IPs (excluding the current worker) in theworker
label.WORKER_LABEL_ID
: Unique identifier for theworker
label.LABELS
: Comma-separated list of roles assigned to the worker.PROMETHEUS_0
: IP address of the first worker with theprometheus
label.PROMETHEUS_ALLOCATION_INDEX
: The index of the current worker in theprometheus
label.PROMETHEUS_WORKERS_LENGTH
: Total number of workers with theprometheus
label.PROMETHEUS_WORKERS
: Comma-separated list of all agent IPs in theprometheus
label.PROMETHEUS_LABEL_ID
: Unique identifier for theprometheus
label.
Examples
Worker 10.27.221.181
:
This worker has the labels worker
and prometheus
:
WORKER_0=10.27.221.181
WORKER_1=10.27.221.144
WORKER_2=10.27.221.170
WORKER_INDEX=0
WORKER_IP=10.27.221.181
WORKER_WORKERS=10.27.221.181,10.27.221.144,10.27.221.170
PROMETHEUS_0=10.27.221.181
PROMETHEUS_INDEX=0
PROMETHEUS_WORKERS=10.27.221.181
LABELS=worker,prometheus
Worker 10.27.221.144
:
This worker has only the worker
label:
WORKER_0=10.27.221.181
WORKER_1=10.27.221.144
WORKER_2=10.27.221.170
WORKER_INDEX=1
WORKER_IP=10.27.221.144
WORKER_WORKERS=10.27.221.181,10.27.221.144,10.27.221.170
PROMETHEUS_WORKERS=10.27.221.181
LABELS=worker
Worker 10.27.221.170
:
This worker has only the worker
label:
WORKER_0=10.27.221.181
WORKER_1=10.27.221.144
WORKER_2=10.27.221.170
WORKER_INDEX=2
WORKER_IP=10.27.221.170
WORKER_WORKERS=10.27.221.181,10.27.221.144,10.27.221.170
PROMETHEUS_WORKERS=10.27.221.181
LABELS=worker
Usage in Jobs
These variables allow dynamic behavior in jobs:
- Static Discovery: Use
WORKER_WORKERS
orWORKER_PEERS
for distributed applications. - Worker-Specific Logic: Use
PROMETHEUS_WORKERS
for tasks targetingprometheus
workers. - Worker Customization: Tailor configurations based on
WORKER_INDEX
orWORKER_IP
.
This approach ensures scalability and simplifies multi-agent orchestration!