Outside Kubernetes
Run the LogDrop Java agent on a host, as a systemd service or in a container.
Outside Kubernetes you start the JVM with one extra flag, -javaagent, and configure the agent with LOGDROP_* environment variables.
You need a traces ingest key and the other items in Before you start, and the Java requirements.
1. Download the agent and store the key
The agent is one jar file that the JVM loads when it starts, and it reads the traces ingest key from a file. Download the agent, verify it, and store the key in a file that only the service user can read:
sudo mkdir -p /opt/logdrop /etc/logdrop
sudo curl -fsSLo /opt/logdrop/logdrop-javaagent.jar \
https://artifactory.logdrop.io/repository/logdrop-java/io/logdrop/logdrop-javaagent/0.1.0-alpha5/logdrop-javaagent-0.1.0-alpha5.jar
printf 'Traces key (paste it once, then press Enter): ' && read -rs LOGDROP_TRACE_KEY && echo
if [[ $LOGDROP_TRACE_KEY == ldtk_* && ${#LOGDROP_TRACE_KEY} -eq 71 ]]; then
printf '%s' "$LOGDROP_TRACE_KEY" | sudo tee /etc/logdrop/trace-ingest-key >/dev/null
else
echo 'That is not one traces key (it starts with ldtk_ and has 71 characters). Paste it once.'
fi
unset LOGDROP_TRACE_KEY
sudo chown <service user> /etc/logdrop/trace-ingest-key && sudo chmod 600 /etc/logdrop/trace-ingest-key2. Start the JVM with the agent
The -javaagent flag loads the agent into the JVM. The LOGDROP_* variables tell it where to send traces, which key file to read and how your service appears in APM:
export LOGDROP_ENDPOINT=https://otel.logdrop.io
export LOGDROP_INGEST_KEY_FILE=/etc/logdrop/trace-ingest-key
export LOGDROP_SERVICE=orders
export LOGDROP_ENVIRONMENT=production
export LOGDROP_RELEASE=1.4.2
java -javaagent:/opt/logdrop/logdrop-javaagent.jar -jar orders.jarThe process then writes one line to standard error:
[logdrop-agent] INFO LogDrop Java agent 0.1.0-alpha5 is tracing service "orders" (environment "production") to otel.logdrop.io.As a systemd service
If systemd runs your service, set the same variables in its unit file and add the agent through JAVA_TOOL_OPTIONS, which the JVM reads when it starts:
[Service]
Environment=LOGDROP_ENDPOINT=https://otel.logdrop.io
Environment=LOGDROP_INGEST_KEY_FILE=/etc/logdrop/trace-ingest-key
Environment=LOGDROP_SERVICE=orders
Environment=LOGDROP_ENVIRONMENT=production
Environment=JAVA_TOOL_OPTIONS=-javaagent:/opt/logdrop/logdrop-javaagent.jar
ExecStart=/usr/bin/java -jar /opt/orders/orders.jarIn a container without Kubernetes
Mount the jar and the key file read-only and set the same variables:
docker run -v /opt/logdrop/logdrop-javaagent.jar:/logdrop/logdrop-javaagent.jar:ro \
-v /etc/logdrop/trace-ingest-key:/run/secrets/logdrop-trace-ingest-key:ro \
-e JAVA_TOOL_OPTIONS=-javaagent:/logdrop/logdrop-javaagent.jar \
-e LOGDROP_ENDPOINT=https://otel.logdrop.io -e LOGDROP_INGEST_KEY_FILE=/run/secrets/logdrop-trace-ingest-key \
-e LOGDROP_SERVICE=orders -e LOGDROP_ENVIRONMENT=production <your image>The key in a file or in a variable
LOGDROP_INGEST_KEY (the key itself in a variable) works too, but prefer the file:
- the agent re-reads the file every 10 seconds, so you can rotate the key without a restart;
- a variable is visible to anyone who can read the process environment.
Set one of the two, not both.
Things to know
- Outside containers, the agent adds the host ID and host name to every trace.
- Each process gets a new instance ID in APM. Set
LOGDROP_SERVICE_INSTANCE_IDto a stable value if restarts should count as the same instance. - The agent keeps the spans waiting to be sent in memory (at most 2,048 by default), not on disk.
- Size the host for about 100 MiB more memory per JVM and about one second more startup time.
All settings are listed in Agent settings.
.png)