# On-Demand Mode
To begin capturing troubleshooting artifacts from your database, you'll need to download and configure the yc-360 script. On-Demand Mode is the most commonly used execution mode for databases. It allows you to manually trigger the script whenever needed. The yc-360 script collects critical database diagnostics such as sessions, queries, locks, deadlocks, and system metrics from your target database, then automatically uploads them to the yCrash server for analysis and root cause identification.
Choose your environment to follow step-by-step instructions:
1. Create a directory for yc-360 script
mkdir -p /opt/workspace/yc-360
cd /opt/workspace/yc-360
2
2. Download the latest yc-360 script
wget https://tier1app.com/dist/ycrash/yc-360-latest.zip
3. Extract the downloaded zip file
unzip yc-360-latest.zip
4. After unzipping, navigate to the linux directory. Inside this directory, select the yc-360 script that matches your server's architecture (amd64 or arm64).
5. Download the YAML Configuration File: Use the following command to download the sample yc-config.yaml configuration template.
wget https://tier1app.com/dist/docs/yc-360-script/database/on-demand/yc-config.yaml
Replace the placeholders in the YAML configuration file with your actual values:
{API_KEY}: Your API key was provided with your license at the time of registration. If you're not sure where to find the API key, click here (opens new window).{http://MY-YC-SERVER:PORT}: URL of the yCrash server (e.g., http://localhost:8080 (opens new window)). If you're not sure where to find the Server URL, click here (opens new window).{TARGET_ID}: A short name for this database, for exampleorders-db. To capture several databases in one run, add one- id:block per database, each with its own name.{DB_HOST}and{DB_PORT}: Address and port of the PostgreSQL server, usuallylocalhostand5432when the script runs on the database host.{DATABASE_NAME}: The database to capture. Server-wide data such as sessions, connections, checkpoints and logs cover the whole server.password: The monitoring user's password.${YC_PG_PASSWORD}reads it from the environment variableYC_PG_PASSWORD, so it isn't stored in the file.tls.enabled: Set totrueto encrypt the connection to PostgreSQL; required by most managed and cloud databases.captureDuration: How long the capture runs (s,morh, for example2mor2h). Required. Default2m.frequency: How often counters are sampled during the capture. Default5m; use30sfor short captures.explain: Captures execution plans of slow queries (needs step 5).loggeduses only the execution plans that PostgreSQL wrote to its log; it runs nothing extra on your database.allalso runsEXPLAIN(neverEXPLAIN ANALYZE) to get estimated plans for other queries; this needs theGRANT SELECTfrom step 5. Leave the key out to capture no plans. A maximum of 5 plans is collected per capture.
For a full list of arguments, refer to the All yc-360 Script Arguments (opens new window) page.
6. Execute yc-360 Script: Run the yc script on Linux Terminal with your target database:
For PostgreSQL:
export YC_PG_PASSWORD='{PASSWORD}'
./yc -c yc-config.yaml
2
INFO:
- Run the yc-360 script on the database host. Deadlocks, timeouts, errors and checkpoint times are read from the PostgreSQL log file, and the script can only read it locally.
- The user running the script needs read access to the PostgreSQL log directory (by default
$PGDATA/log). Run it as thepostgresOS user, or add your user to the group that owns the log files. - After the first capture, check that log reading works: the capture's
pg_metadata.txtshould showlog_access,direct. - For logged plans, PostgreSQL must log a matching plan during the capture. Check the configured duration threshold (
auto_explain.log_min_duration). If the Plan tab shows "No plan was captured", check that step 5 is done andexplainis set.
You can run the yc-360 script in a Docker environment using one of the following approaches, depending on your deployment setup and monitoring preferences.
# 1. Run yc-360 Script in Sidecar Container
Add the yc-360 script as a sidecar container alongside your database container in your Docker Compose or Kubernetes pod spec. The sidecar shares the network namespace with your application, allowing it to connect to the PostgreSQL database.
Docker Compose example:
version: '3.8'
services:
app:
image: myapp:latest
ports: ["8080:8080"]
environment:
- POSTGRES_HOST=db
- POSTGRES_DB=mydb
- POSTGRES_USER=yc_monitor
- POSTGRES_PASSWORD=${YC_PG_PASSWORD}
yc-360:
image: ycrash/yc-360:latest
depends_on: [app]
environment:
- YC_PG_PASSWORD=${YC_PG_PASSWORD}
- PG_HOST=db
- PG_DATABASE=mydb
- PG_USER=yc_monitor
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Run the capture:
docker-compose up yc-360
# 2. Run yc-360 Script in Same Container
Embed the yc-360 script directly inside your application container. This approach requires the script to be included in your Docker image.
Dockerfile example:
FROM python:3.9-slim
# Install yc-360 script
RUN wget https://tier1app.com/dist/ycrash/yc-360-latest.zip && \
unzip yc-360-latest.zip -d /opt/yc-360 && \
chmod +x /opt/yc-360/yc
# Set environment variables for database capture
ENV YC_PG_PASSWORD=${YC_PG_PASSWORD}
ENV PG_HOST=db
ENV PG_DATABASE=mydb
ENV PG_USER=yc_monitor
# Copy YAML config
COPY yc-config.yaml /opt/yc-360/yc-config.yaml
# Run yc-360 script
CMD ["/opt/yc-360/yc", "-c", "/opt/yc-360/yc-config.yaml"]
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Build and run:
docker build -t myapp:with-yc-360 .
docker run -d myapp:with-yc-360
2
# 3. Run yc-360 Script on Host
Run the yc-360 script directly on the host machine where Docker containers are running. This approach requires the host to have network access to the PostgreSQL database.
Run the capture:
mkdir -p /opt/workspace/yc-360
cd /opt/workspace/yc-360
wget https://tier1app.com/dist/ycrash/yc-360-latest.zip
unzip yc-360-latest.zip
export YC_PG_PASSWORD={PASSWORD}
./yc -c yc-config.yaml
2
3
4
5
6
IMPORTANT TIP:
- Ensure the host can reach the PostgreSQL database (check network connectivity, security groups, and firewall rules).
- The yc-360 script connects to the database using the provided credentials; make sure the PostgreSQL server accepts connections from the host's IP address.
You can run the yc-360 script in a Kubernetes environment using one of the following approaches, depending on your deployment setup and monitoring preferences.
# 1. Run yc-360 Script as a Sidecar Container
Add the yc-360 script as a sidecar container in your pod spec. The sidecar shares the pod's network namespace with your application, allowing it to connect to the PostgreSQL database.
Pod spec example:
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
spec:
containers:
- name: myapp
image: myapp:latest
env:
- name: POSTGRES_HOST
value: "db-service.my-namespace.svc.cluster.local"
- name: POSTGRES_DB
value: "mydb"
- name: POSTGRES_USER
value: "yc_monitor"
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: pg-credentials
key: password
- name: yc-360
image: ycrash/yc-360:latest
env:
- name: YC_PG_PASSWORD
valueFrom:
secretKeyRef:
name: pg-credentials
key: password
- name: PG_HOST
value: "db-service.my-namespace.svc.cluster.local"
- name: PG_DATABASE
value: "mydb"
- name: PG_USER
value: "yc_monitor"
volumeMounts:
- name: yc-data
mountPath: /yc-data
command: ["./yc", "-c", "/yc-config/yc-config.yaml"]
volumes:
- name: yc-data
emptyDir: {}
- name: yc-config
configMap:
name: yc-config
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Create the config map:
kubectl create configmap yc-config --from-file=yc-config.yaml
Run the capture:
kubectl apply -f pod.yaml
# 2. Run yc-360 Script in Same Container
Embed the yc-360 script directly inside your application container. This approach requires the script to be included in your Docker image.
Dockerfile example:
FROM postgres:14
# Install yc-360 script
RUN wget https://tier1app.com/dist/ycrash/yc-360-latest.zip && \
unzip yc-360-latest.zip -d /opt/yc-360 && \
chmod +x /opt/yc-360/yc
# Set environment variables for database capture
ENV YC_PG_PASSWORD=${YC_PG_PASSWORD}
ENV PG_HOST=db-host
ENV PG_DATABASE=mydb
ENV PG_USER=yc_monitor
# Copy YAML config
COPY yc-config.yaml /opt/yc-360/yc-config.yaml
# Run yc-360 script
CMD ["/opt/yc-360/yc", "-c", "/opt/yc-360/yc-config.yaml"]
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Build and run:
docker build -t mypostgres:with-yc-360 .
kubectl set image deployment/my-postgres my-postgres=mypostgres:with-yc-360
2
IMPORTANT TIP:
- Ensure the Kubernetes pod has network access to the PostgreSQL service.
- If using a ClusterIP service, the yc-360 script can connect using the service name.
- For external databases, ensure the appropriate network policies and security groups allow traffic from the pod's subnet.
To monitor applications running on OpenShift, deploy the yc-360 script using a sidecar container deployment.
OpenShift route example:
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:latest
env:
- name: POSTGRES_HOST
value: "db-service.my-project.svc.cluster.local"
- name: POSTGRES_DB
value: "mydb"
- name: POSTGRES_USER
value: "yc_monitor"
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: pg-credentials
key: password
- name: yc-360
image: ycrash/yc-360:latest
env:
- name: YC_PG_PASSWORD
valueFrom:
secretKeyRef:
name: pg-credentials
key: password
- name: PG_HOST
value: "db-service.my-project.svc.cluster.local"
- name: PG_DATABASE
value: "mydb"
- name: PG_USER
value: "yc_monitor"
volumeMounts:
- name: yc-data
mountPath: /yc-data
command: ["./yc", "-c", "/yc-config/yc-config.yaml"]
volumes:
- name: yc-data
emptyDir: {}
- name: yc-config
configMap:
name: yc-config
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Create the config map:
oc create configmap yc-config --from-file=yc-config.yaml
Run the capture:
oc apply -f pod.yaml
IMPORTANT TIP:
- OpenShift may require security context constraints (SCCs) to allow the yc-360 sidecar to run. Ensure the SCC permits the necessary capabilities.
- The yc-360 script connects to the PostgreSQL service using the service name; ensure the service is accessible within the OpenShift cluster.
You can run the yc-360 script in an AWS Fargate environment using one of the following approaches, depending on your orchestration platform.
# 1. Fargate on ECS
ECS task definition example:
{
"family": "myapp-task",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "1024",
"memory": "2048",
"containerDefinitions": [
{
"name": "app",
"image": "myapp:latest",
"environment": [
{ "name": "POSTGRES_HOST", "value": "my-db.example.com" },
{ "name": "POSTGRES_DB", "value": "mydb" },
{ "name": "POSTGRES_USER", "value": "yc_monitor" },
{ "name": "POSTGRES_PASSWORD", "value": "${YC_PG_PASSWORD}" }
]
},
{
"name": "yc-360",
"image": "ycrash/yc-360:latest",
"essential": false,
"environment": [
{ "name": "YC_PG_PASSWORD", "value": "${YC_PG_PASSWORD}" },
{ "name": "PG_HOST", "value": "my-db.example.com" },
{ "name": "PG_DATABASE", "value": "mydb" },
{ "name": "PG_USER", "value": "yc_monitor" }
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/myapp",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "yc-360"
}
}
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Run the capture:
Deploy the task definition through the AWS Console, CLI, or CDK. The yc-360 sidecar will capture PostgreSQL metrics for the configured duration and upload the data to the yCrash server.
IMPORTANT TIP:
- Ensure the Fargate task has the necessary IAM permissions to send data to the yCrash server.
- The sidecar container shares the ENI with the application container, allowing it to connect to the PostgreSQL database using the service hostname or IP address.
- Set the
captureDurationandfrequencyin the YAML configuration to control the capture window and sampling frequency.