Skip to content

Pyroscope Server

Pyroscope Server in Pyroscope Guide.

4 min read Updated SS MR

Pyroscope Server#

Introduction#

Grafana Pyroscope collects continuous profiles from the target services to display CPU and memory hotspots in production with minimal overhead.​ It scales horizontally and integrates with Grafana, so end users can correlate profiles with the metrics, logs, and traces during incident response.

Configuration#

Configure the Pyroscope by following these steps: 

1. Navigate to the following path: 

<HEAL directory>/Appsone_Service

a. Create a pyroscope directory.

b. Create a pyroscope.yml file and copy the following content into the file.

server:
  grpc_listen_port: 9096

tracing:
  enabled: true
  profiling_enabled: true

pyroscopedb:
  max_block_duration: 5m

self_profiling:
  disable_push: true

limits:
  ingestion_rate_mb: 32
  ingestion_burst_size_mb: 16
  max_profile_size_bytes: 0
  max_profile_stacktrace_samples: 0

storage:
  backend: s3
 s3:
   bucket_name: grafana-pyroscope-data
   endpoint: <minio-server-ip>:9000 #For example: endpoint: 192.0.2.130:9000
   insecure: true
   access_key_id: <minio non-root user> #For example: access_key_id: <username>
   secret_access_key: <minio non-root user's password> #For example: secret_access_key: <password>

Docker#

Run the Pyroscope container with the configuration file mounted.​

docker run --name='pyroscope' -v <HEAL directory>/Appsone_Service/pyroscope/pyroscope.yml:/etc/pyroscope.yml --cpus="4.0" --memory="4g" --network=host -d grafana/pyroscope:1.14.0 -config.file=/etc/pyroscope.yml

Ports#

4040 – Pyroscope HTTP API/UI and ingestion endpoint for agents and Grafana queries.​

Tempo server#

Introduction#

The Grafana Tempo stores and queries distributed traces from target services at scale using object storage rather than indexing, keeping retention high.​ 

Configuration#

Configure the Tempo server by following these steps: 

1. Navigate to the following path: 

<HEAL directory>/Appsone_Service

a. Create a tempo directory.

b. Create a tempo.yml file and copy the following content into the file.

server:
  http_listen_port: 3200

query_frontend:
  search:
   duration_slo: 5s
   throughput_bytes_slo: 1.073741824e+09
  trace_by_id:
   duration_slo: 5s

distributor:
 receivers:    
   jaeger:   
   protocols:  
   thrift_http: 
 grpc: 
   endpoint: 0.0.0.0:14255
   thrift_binary:
   thrift_compact:
   zipkin:
   otlp:
   protocols:
   http:
   grpc:
   endpoint: 0.0.0.0:4321
   opencensus:

compactor:
  compaction:
  block_retention: 48h

storage:
  trace:
  backend: s3
  s3:
  endpoint: <minio-server-ip>:9000 #For example: endpoint: 192.0.2.130:9000
  bucket: grafana-traces-data
  forcepathstyle: true
  enable_dual_stack: false
    insecure: true
  access_key: <minio non-root user>   #For example: access_key: <username>
  secret_key: <minio non-root user's password> #For example: secret_key: puser@123
  wal:
  path: /var/tempo/wal
  local:
  path: /var/tempo/blocks

overrides:
   defaults:
   ingestion:
   rate_strategy: local
   burst_size_bytes: 40000000
   rate_limit_bytes: 30000000   

Docker#

Run the Tempo container with the configuration file mounted.​

docker run --name='tempo' -v <HEAL directory>/Appsone_Service/tempo/tempo.yml:/etc/tempo.yml --cpus="4.0" --memory="4g" --network=host -d grafana/tempo:2.8.1 -config.file=/etc/tempo.yml

Ports#

4321 – OTLP gRPC traces ingestion from agents and SDKs.​

14255 – Jaeger gRPC ingestion from agents and collectors.​

3200 – HTTP API for queries from Grafana.​

Grafana server#

Introduction#

Grafana dashboards help with ad‑hoc exploration across metrics, logs, traces, and profiles through a pluggable data‑source model.​ This provides real‑time visibility into the modules, controllers, and external integrations. 

Perform the configurations below on the Grafana server:

Docker#

Execute the following command in a Docker container.

docker run --name='grafana' --env=GF_SERVER_HTTP_PORT=3003 --env=GF_AUTH_ANONYMOUS_ENABLED=true --env=GF_AUTH_ANONYMOUS_ORG_ROLE=Admin --env=GF_AUTH_DISABLE_LOGIN_FORM=true --env=GF_INSTALL_PLUGINS=grafana-pyroscope-app --env=GF_FEATURE_TOGGLES_ENABLE='traceToProfiles tracesEmbeddedFlameGraph' --cpus="1.0" --memory="2g" --network=host -d grafana/grafana:12.0.2

Post-Setup Config#

1. Open http://<grafana-ip>:3003 in a web browser. 

2. Add a new Pyroscope data source as below:

  • Configure the URL as http://<pyroscope-server-ip>:4040.

The output is obtained as in the highlighted section. 

3. Add a new tempo data source as below:

  • Configure the URL as http://<tempo-server-ip>:3200.

The output is obtained as in the highlighted section.

Ports#

3000 - Ensure the port is open for Grafana UI access to trace and profiling dashboards.

Target Java Application#

Introduction#

The Java services use the OpenTelemetry Java agent for zero‑code instrumentation to emit traces and metrics to the observability backend.​ Agent settings such as service name and OTLP endpoint are configured via JVM flags or environment variables for consistent telemetry across components. 

Follow the steps below for agent configuration: 

1. Create a Pyroscope folder inside the healagent directory.

a. Copy the downloaded pyroscope-otel-0.10.3-custom.jar file inside the Pyroscope folder.

2. Configure the YAML file as below:

a. Add the following arguments in JAVA_TOOL_OPTIONS:

    • -XX:+UnlockDiagnosticVMOptions
    • -XX:+DebugNonSafepoints
    • -Dotel.javaagent.extensions=/healagent/pyroscope/pyroscope-otel-0.10.3-custom.jar"

b. Add the environmental variables:

OTEL_PYROSCOPE_ADD_PROFILE_BASELINE_URL="false"
OTEL_PYROSCOPE_ADD_PROFILE_URL="false"
OTEL_PYROSCOPE_START_PROFILING="true"
PYROSCOPE_APPLICATION_NAME="<provide the service name>" #For example: "petclinic-java21"
PYROSCOPE_FORMAT="jfr"
PYROSCOPE_LABELS="hostname=<provide the hostname>" #For example: "6node-server3"
PYROSCOPE_LOG_LEVEL="debug"
PYROSCOPE_PROFILER_ALLOC="512k"
PYROSCOPE_PROFILER_EVENT="ctimer"
PYROSCOPE_PROFILER_LOCK="10ms"
PYROSCOPE_PROFILER_PER_THREAD="true"
PYROSCOPE_PROFILING_INTERVAL="10ms"
PYROSCOPE_SERVER_ADDRESS="http://<HAProxy-server-address>:9998" #For example: "https://192.0.2.132:9998"
PYROSCOPE_UPLOAD_INTERVAL="3s"

For example:

containers:
- name: gateway
image: 'jfrog.bank.example/app-signed-images/gateway:0.40.0-BI'
env:
- name: JAVA_TOOL_OPTIONS
value: "-Dotel.javaagent.configuration-file=/healagent/agent-cache.properties -javaagent:/healagent/heal-jim-opentelemetry-javaagent-1.3.0-SNAPSHOT.jar -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -Dotel.javaagent.extensions=/healagent/pyroscope-otel-0.10.3-custom.jar"
- name: OTEL_PYROSCOPE_ADD_PROFILE_BASELINE_URL
value: "false"
- name: OTEL_PYROSCOPE_ADD_PROFILE_URL
value: "false"
- name: OTEL_PYROSCOPE_START_PROFILING
value: "true"
- name: PYROSCOPE_APPLICATION_NAME
value: "<provide the service name>"
- name: PYROSCOPE_FORMAT
value: "jfr"
- name: PYROSCOPE_LABELS
value: "hostname=<provide the hostname>"
- name: PYROSCOPE_LOG_LEVEL
value: "debug"
- name: PYROSCOPE_PROFILER_ALLOC
value: "512k"
- name: PYROSCOPE_PROFILER_EVENT
value: "ctimer"
- name: PYROSCOPE_PROFILER_LOCK
value: "10ms"
- name: PYROSCOPE_PROFILER_PER_THREAD
value: "true"
- name: PYROSCOPE_PROFILING_INTERVAL
value: "10ms"
- name: PYROSCOPE_SERVER_ADDRESS
value: "http://<HAProxy-server-address>:9998"
- name: PYROSCOPE_UPLOAD_INTERVAL
value: "3s"
volumeMounts:
- mountPath: /healagent
name: agent-repo

Note: The highlighted parameters are newly added arguments.

3. Start/Restart the respective application.