Monitoring Auxiliary PDF Service
This section describes how the PDF Render Service can be monitored, and metrics obtained.
Monitoring with the UI
To monitor auxiliary services within the UI, visit the
Auxiliary services page.
Health and Metrics
The PDF Render Service provides two endpoints
/health and /metrics.
The /status endpoint returns a status of
OK if everything is running well and there are no
problems. The /metrics endpoint returns metrics
quantifying the running of the service. The following example
demonstrates the type of information returned.
A GET request on the example endpoint
https://pdf-render-service.example.com/metrics
would return data in the Prometheus text-based format similar to the
following:
# HELP logscale_pdf_render_service_uptime_seconds The uptime in seconds for this service.
# TYPE logscale_pdf_render_service_uptime_seconds counter
logscale_pdf_render_service_uptime_seconds 78472
# HELP logscale_pdf_render_service_total_requests The total number of requests.
# TYPE logscale_pdf_render_service_total_requests counter
logscale_pdf_render_service_total_requests 2
# HELP logscale_pdf_render_service_accepted_requests The number of requests that were accepted by this service.
# TYPE logscale_pdf_render_service_accepted_requests counter
logscale_pdf_render_service_accepted_requests 2
# HELP logscale_pdf_render_service_rejected_requests The number of requests that were rejected by this service.
# TYPE logscale_pdf_render_service_rejected_requests counter
logscale_pdf_render_service_rejected_requests 0
# HELP logscale_pdf_render_service_successful_requests The number of requests that were completed successfully by this service.
# TYPE logscale_pdf_render_service_successful_requests counter
logscale_pdf_render_service_successful_requests 2
# HELP logscale_pdf_render_service_failed_requests The number of requests that failed in this service.
# TYPE logscale_pdf_render_service_failed_requests counter
logscale_pdf_render_service_failed_requests 0
# HELP logscale_pdf_render_service_failed_pdf_generation_attempts The number of failed attempts to generate a PDF.
# TYPE logscale_pdf_render_service_failed_pdf_generation_attempts counter
logscale_pdf_render_service_failed_pdf_generation_attempts 0
# HELP logscale_pdf_render_service_total_queue_slots The total number of available slots in the queue.
# TYPE logscale_pdf_render_service_total_queue_slots gauge
logscale_pdf_render_service_total_queue_slots 40
# HELP logscale_pdf_render_service_available_queue_slots The number of currently available slots in the queue.
# TYPE logscale_pdf_render_service_available_queue_slots gauge
logscale_pdf_render_service_available_queue_slots 40
# HELP logscale_pdf_render_service_queue_slots_usage_percentage The percentage of queue slots that are currently in use.
# TYPE logscale_pdf_render_service_queue_slots_usage_percentage gauge
logscale_pdf_render_service_queue_slots_usage_percentage 0
# HELP logscale_pdf_render_service_avg_queue_size The average queue size upon accepting a request.
# TYPE logscale_pdf_render_service_avg_queue_size gauge
logscale_pdf_render_service_avg_queue_size 0
# HELP logscale_pdf_render_service_avg_processing_time_seconds The average processing time for accepted requests.
# TYPE logscale_pdf_render_service_avg_processing_time_seconds gauge
logscale_pdf_render_service_avg_processing_time_seconds 30.96In a typical setup, you would also configure the service to write events into LogScale. These could then be queried with queries such as:
"#repo"="example_k8s" "#service_name"="kube:container:pdf-render-service"This would return a list of events associated with the PDF Render Service.
You can get some more details of these endpoints by pointing your
browser at the api.yaml your PDF Render Service.
For example,
https://pdf-render-service.example.com/api.yaml
would return:
/health:
get:
summary: Health endpoint for render service
description: Check if the service is alive
responses:
'200':
description: The service is alive
/metrics:
get:
summary: Service metrics
description: Responds with a collection of metrics for the running service in the Prometheus text based format
responses:
'200':
description: A collection of metrics
content:
text/plain:
schema:
type: string
examples:
textExample:
summary: An example of the Prometheus text-based format
externalValue: 'https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#text-format-example'Monitoring with GraphQL API
Auxiliary services can also be monitoring through the servicesMetadata GraphQL query:
query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @- << EOF
{"query" : "query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}"
}
EOFcurl -v -X POST $YOUR_LOGSCALE_URL/graphql \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @- << EOF
{"query" : "query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}"
}
EOFcurl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
-H "Authorization: Bearer $TOKEN" ^
-H "Content-Type: application/json" ^
-d @'{"query" : "query { ^
servicesMetadata { ^
name, ^
serviceType, ^
endpointUrl, ^
healthStatus {status,message} ^
} ^
}" ^
} 'curl.exe -X POST
-H "Authorization: Bearer $TOKEN"
-H "Content-Type: application/json"
-d '{"query" : "query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}"
}'
"$YOUR_LOGSCALE_URL/graphql"#!/usr/bin/perl
use HTTP::Request;
use LWP;
my $TOKEN = "TOKEN";
my $uri = '$YOUR_LOGSCALE_URL/graphql';
my $query = "query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );
$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");
$req->content( $json );
my $lwp = LWP::UserAgent->new;
my $result = $lwp->request( $req );
print $result->{"_content"},"\n";#! /usr/local/bin/python3
import requests
url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}"
}'''
resp = requests.post(url,
data = mydata,
headers = {
"Authorization" : "Bearer $TOKEN",
"Content-Type" : "application/json"
}
)
print(resp.text)const https = require('https');
const data = JSON.stringify(
{"query" : "query {
servicesMetadata {
name,
serviceType,
endpointUrl,
healthStatus {status,message}
}
}"
}
);
const options = {
hostname: '$YOUR_LOGSCALE_URL',
path: 'graphql',
port: 443,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
Authorization: 'BEARER ' + process.env.TOKEN,
'User-Agent': 'Node',
},
};
const req = https.request(options, (res) => {
let data = '';
console.log(`statusCode: ${res.statusCode}`);
res.on('data', (d) => {
data += d;
});
res.on('end', () => {
console.log(JSON.parse(data).data);
});
});
req.on('error', (error) => {
console.error(error);
});
req.write(data);
req.end();This will output a list of the configured services:
{
"data": {
"servicesMetadata": [
{
"name": "default-pdf-render-service",
"serviceType": "pdf-render-service",
"endpointUrl": "http://pdf-render.local:5123",
"healthStatus": {
"status": "OK",
"message": "HttpEntity.Strict(text/html; charset=UTF-8,2 bytes total)"
}
}
]
},
}