Service installation and deployment
1. Introduction
The service is dockerized, and a Docker image is available in a Facephi repository.
docker login facephicorp.jfrog.io
user: username
pass: tokendocker pull facephicorp.jfrog.io/docker-pro-fphi/facephi-selphid-sdk:#VERSION#Where #VERSION# is the specific version number you want to download (e.g. 6.22.0).
2. docker-compose
One way to deploy the service is to create a file docker-compose.yml with the following content, modifying the variable values as needed.
version: '3.7'
services:
selphid-service:
ports:
- "8080:8080"
volumes:
- /home/user/selphid/config:/app/selphid-sdk/config
image: facephicorp.jfrog.io/docker-pro-fphi/facephi-selphid-sdk:#VERSION#
container_name: facephi-selphid-sdkFirst, create a user directory with read and write permissions, for example /home/user/selphid/config, and place these two files in it:
The License file
license.lic(required).The service configuration file
config.json(optional).
Run the following command from the folder containing the file docker-compose.yml, to deploy the service:
3. Additional Configuration
Following the steps in section 2, the service is ready to start. If you need to create additional volumes for the different types of assets, you can use the following additional configurations.
3.1 License
You can mount an additional volume and define the environment variable LICENSE_PATH, if you want to install the license outside the usual configuration directory.
3.2 Service
If you need to configure the service, you must provide a config.json, as described in section 2. If you want to place this file in an additional volume:
If no config.jsonis specified, these default values will be used:
JWT authentication is optional and disabled by default. Its operation is described in section 4, and the operational metrics and their thresholds are described in section 6.
Starting with version 6.19.0, the following environment variables are added to set the values in config.json:
Starting with version 6.22.0, JWT authentication and operational metrics variables are also supported:
Environment variables take precedence over config.json, and both take precedence over the default values.
The configuration cannot be modified at runtime: to change it, update config.json or the environment variables and restart the service. Starting with version 6.22.0, POST /api/v1/selphid/config always responds with 400 Bad Request with a message indicating the reason (up to version 6.21.0, it responded 200 without applying any changes).
3.3 Debug and usage paths
Finally, you can specify a specific volume/path with read and write permissions for SDK debug information and SDK usage data using the environment variables DEBUG_PATH and USAGE_PATH:
4. JWT authentication
Starting with version 6.22.0, the service supports optional JWT authentication, disabled by default. It is configured at startup in config.json or using the environment variables FACEPHI_SELPHID_REST_AUTH_*:
auth_enabled
FACEPHI_SELPHID_REST_AUTH_ENABLED
false
Requires a valid JWT on protected endpoints
auth_jwt_secret
FACEPHI_SELPHID_REST_AUTH_JWT_SECRET
""
HS256 shared secret used to validate JWTs
auth_accept_authorization_header
FACEPHI_SELPHID_REST_AUTH_ACCEPT_AUTHORIZATION_HEADER
true
Accepts the token in the header Authorization: Bearer <jwt>
auth_accept_api_key_header
FACEPHI_SELPHID_REST_AUTH_ACCEPT_API_KEY_HEADER
true
Accepts the token as-is, without the prefix Bearer, in the header specified by auth_api_key_header_name
auth_api_key_header_name
FACEPHI_SELPHID_REST_AUTH_API_KEY_HEADER_NAME
x-api-key
API key header name
With authentication enabled:
All endpoints require a JWT, except
GET /api/v1/selphid/health,GET /api/v1/selphid/version,GET /api/v1/selphid/metrics,GET /api/v1/selphid/metrics/prometheusandOPTIONSrequests (CORS preflight).The token must be signed with HS256 using
auth_jwt_secretand include the claimexp. Time-based claims (expand, if present,nbfandiat) are checked with a 60-second tolerance to account for small clock differences, so a token is still accepted up to 60 seconds after it expires.Always set
auth_jwt_secretwhen enabling authentication: if it is empty, all protected endpoints respond401withAuthentication secret is not configured.Requests without a token or with an invalid token receive
401 Unauthorized, with the headerWWW-Authenticate: Bearerand this body:
message indicates the reason for the rejection: Missing authentication token, JWT token is expired, JWT token is not yet valid, JWT token does not include exp claim, JWT token validation failed or Authentication secret is not configured.
Authentication parameters are only read at startup:
GET /api/v1/selphid/confignever returns the JWT authentication keys.POST /api/v1/selphid/configrejects JWT authentication keys with400and the messageJWT auth settings are not accessible from the config endpoint. To change them, updateconfig.jsonor the environment variables and restart the service.
Configuration example in config.json:
Example using environment variables in docker-compose.yml:
Example of an authenticated request:
5. Health check
GET /api/v1/selphid/health checks that the SDK is loaded and responding. It is public even when JWT authentication is enabled, so it can be used in container probes.
When the SDK is initialized and responding, the service returns 200:
When the SDK could not be loaded at startup or does not respond to the check, the service returns 503 Service Unavailable. message indicates the reason: SelphID SDK is not initialized or SDK health check failed.
The result of the latest check is stored and published in the state.sdk block of GET /api/v1/selphid/metrics, which never runs the check itself.
6. Operational metrics
Starting with version 6.22.0, the service publishes two operational metrics endpoints. They are available in all image variants and are public even when JWT authentication is enabled:
GET /api/v1/selphid/metrics: an inexpensive JSON snapshot suitable for frequent queries. It does not call the SDK or run the health check.GET /api/v1/selphid/metrics/prometheus: the same snapshot in Prometheus text exposition format (see section 6.4).
Traffic, saturation, latency, and quality figures accumulate in memory from service startup, so they reset when the service restarts.
schemaVersion, timestamp
Format version (1.0) and snapshot time in UTC
service
name (facephi-selphid-service), version, pathBase (/api/v1/selphid), uptimeSeconds and configuredThreads
state
initialized, sdk (result of the latest call to /health: alive, healthy, initialized, lastHealthKnown, lastHealthCheckAt and lastError) and classification (see section 6.1)
traffic
All requests handled, including management requests: totals (requests, success, clientErrors, serverErrors, unauthorized), windows 1m, 5m and 15m (requests, rps, successRate, errorRate, clientErrors, serverErrors, unauthorized) and byEndpoint, with one entry for each endpoint that has already received requests
saturation
inflight, maxInflight1m, configuredThreads, queueP95Ms1m and backlogSuspected
latency
Latencies in milliseconds (avg, p50, p95, p99, max) total (totalMs), queue (queueMs) and SDK processing (sdkMs), per window
usage
Requests handled by each business endpoint in operations, with keys <METHOD> <path> (for example POST /api/v1/selphid/extract), and their sum in total. It does not include management endpoints (health, version, config and metrics). enabled is always true
quality
Aggregated quality of SDK results (see section 6.2)
alerts
Active alerts (see section 6.3)
state.sdkreflects the last call toGET /api/v1/selphid/health. Until the first call,lastHealthKnown,aliveandhealthyarefalse, but the service is not classified asunhealthy. To keep the block up to date, configure a probe that periodically calls/health.errorRatecounts all4xxand5xx, including401and rejections400due to validation errors.
Example (abbreviated):
6.1 Status classification
state.classification summarizes the snapshot in a single value:
unhealthy
The SDK is not initialized, or the last call to /health failed
unknown
There is no traffic, health checks, or quality alerts yet
saturated
There is traffic, and the request queue indicates saturation: saturation.backlogSuspected is true, or in-flight requests exceed configuredThreads × metrics_saturation_min_inflight_ratio with a 95th percentile queue latency over the last minute of at least metrics_saturation_queue_p95_ms
degraded
The 5-minute error rate reaches metrics_error_rate_warning, a server error has occurred (5xx) in the last 5 minutes, or the LOW_QUALITY alert is active
idle
There is traffic, and the requests per second over the last 15 minutes are below metrics_idle_rps_threshold
ok
None of the above cases
Cases are evaluated in the order shown in the table, and the first one that applies is used. The comparison with in-flight requests is strict because the request that reads /metrics counts as an in-flight request.
6.2 Result quality
The quality block aggregates the results returned by the SDK since the service started. Requests rejected before reaching the SDK, for example due to validation errors, are not counted. It is an empty object until the first sample: each block appears with its first sample, and summary, as soon as either one appears.
facialAuthentication
/authenticate-facial/images, /authenticate-facial/image/template, /authenticate-facial/templates, /authenticate-facial/document/face-image and /authenticate-facial/document/face-template
samples, positive (authStatus equal to Positive), negative (any other authStatus) and the summary for similarity
extraction
/extract and /extract/template
okCount, errorCount (invalid extractions), the summary of faceConfidence and the count by facialQuality (facialQualityCounts)
liveness
/passive-liveness/evaluate and /passive-liveness/evaluate/token
The count by diagnostic (diagnosticCounts) and, in noLiveDetails, the counts by fPadStatus and fMadStatus (fPadStatusCounts, fMadStatusCounts) and the summaries of fPadScore, fMadScore and coercionScore
tracking
Authentication and liveness check operations
The count by trackingStatus (statusCounts)
summary
All of the above
lowQualitySamples (low-quality samples since startup) and lowQualitySince (time of the first one; only appears when there is one)
The summaries have the form { "samples", "avg", "min", "max" } and only appear when at least one value has been observed.
A sample is low quality only when the SDK could not evaluate it:
Authentication:
authStatusequal toNoneorNoneBecause*(for example,NoneBecauseInvalidExtractions).Extraction: invalid extraction (
Invalid Extraction),facialQualityequal toBadorfaceConfidenceless than0.5.Liveness check:
diagnosticequal toNoneorNoneBecause*(exceptNoneBecauseTokenSecurity), orfPadStatus/fMadStatusequal toError.
Business verdicts are valid SDK results, not low-quality samples: an authentication Negative or Uncertain, a diagnosis Spoof, NoLive or Uncertain, a PAD/MAD status Failed or NoneBecauseTokenSecurity (a token reused in another session, i.e., a detected attack). They are counted in quality, but do not trigger the LOW_QUALITY alert or degrade the service classification.
6.3 Alerts
code
severity
message
SDK_UNAVAILABLE
critical
SDK health check failed
HIGH_ERROR_RATE
warning
5m error rate is above the warning threshold
SATURATED
warning
Queue latency and inflight indicate saturation
LOW_QUALITY
warning
Recent SelphID quality signals show degraded results
IDLE
info
Traffic is below the idle threshold
Each alert includes code, severity, message and since (UTC timestamp):
SDK_UNAVAILABLEis triggered when the SDK is not initialized or the last call to/healthfailed. Itssinceis the timestamp of that check.HIGH_ERROR_RATEis triggered when the 5-minute error rate, which includes4xxand5xxresponses, reachesmetrics_error_rate_warning.SATURATEDandIDLEaccompany thesaturatedandidle.LOW_QUALITYis triggered by a low-quality sample and remains active while the most recent sample occurred within themetrics_quality_alert_window_secondswindow (900 seconds by default); it clears automatically when that amount of time passes without new samples. Itssinceis the first sample in the current alert, not the first one since startup (which is published inquality.summary.lowQualitySince). With0, the alert is never triggered.For
HIGH_ERROR_RATE,SATURATEDandIDLE,sinceis the timestamp of the snapshot.
6.4 Prometheus exposition
GET /api/v1/selphid/metrics/prometheus returns the same snapshot as Prometheus exposition text (text/plain; version=0.0.4; charset=utf-8). The service-specific series are published first, with the prefix facephi_selphid_, followed by the HTTP-level series, with the prefix facephi_:
facephi_selphid_service_info{name,version,path_base,schema_version}
gauge
Block service, always with a value of 1
facephi_selphid_configured_threads, facephi_selphid_uptime_seconds
gauge
service.configuredThreads and service.uptimeSeconds
facephi_selphid_snapshot_timestamp_seconds
gauge
Snapshot time (timestamp)
facephi_selphid_initialized
gauge
state.initialized
facephi_selphid_sdk_alive, facephi_selphid_sdk_last_health_known, facephi_selphid_sdk_last_health_check_timestamp_seconds
gauge
Block state.sdk
facephi_selphid_state_classification{classification}
gauge
state.classification: value 1 for the current value and 0 for the rest
facephi_selphid_usage_counters_enabled
gauge
usage.enabled
facephi_selphid_usage_operations_total{operation}, facephi_selphid_usage_total
counter
Block usage; operation value <METHOD> <path>
facephi_selphid_authentication_samples_total, facephi_selphid_authentication_results_total{result}
counter
quality.facialAuthentication; result value positive or negative
facephi_selphid_extraction_results_total{result}
counter
quality.extraction; result value ok or error
facephi_selphid_extraction_facial_quality_total{quality}
counter
quality.extraction.facialQualityCounts
facephi_selphid_liveness_diagnostics_total{diagnostic}
counter
quality.liveness.diagnosticCounts
facephi_selphid_liveness_fpad_status_total{status}, facephi_selphid_liveness_fmad_status_total{status}
counter
quality.liveness.noLiveDetails.fPadStatusCounts and fMadStatusCounts
facephi_selphid_tracking_status_total{status}
counter
quality.tracking.statusCounts
facephi_selphid_quality_score_samples, facephi_selphid_quality_score_avg, facephi_selphid_quality_score_min, facephi_selphid_quality_score_max (labels operation and metric)
gauge
Summaries of quality: similarity in facialAuthentication, faceConfidence in extraction, and fPadScore, fMadScore and coercionScore in liveness
facephi_selphid_low_quality_samples, facephi_selphid_low_quality_since_timestamp_seconds
gauge
Block quality.summary
facephi_selphid_alert_active{code,severity}, facephi_selphid_alert_since_timestamp_seconds{code,severity}
gauge
Block alerts: value 1 for active alerts and 0 for the rest
facephi_requests_total, facephi_request_success_total, facephi_request_client_errors_total, facephi_request_server_errors_total, facephi_request_unauthorized_total
counter
Block totals traffic
facephi_endpoint_requests_total{method,path}, facephi_endpoint_request_success_total{method,path}, facephi_endpoint_request_client_errors_total{method,path}, facephi_endpoint_request_server_errors_total{method,path}, facephi_endpoint_request_unauthorized_total{method,path}
counter
Breakdown of traffic by endpoint
facephi_endpoint_inflight_requests{method,path}
gauge
In-flight requests by endpoint
facephi_window_requests{window}, facephi_window_rps{window}, facephi_window_success_rate{window}, facephi_window_error_rate{window}, facephi_window_client_errors{window}, facephi_window_server_errors{window}, facephi_window_unauthorized{window}
gauge
Windows 1m, 5m and 15m of traffic
facephi_inflight_requests, facephi_configured_threads, facephi_backlog_suspected, facephi_max_inflight_requests{window}
gauge
Block saturation
facephi_total_latency_ms{window,stat}, facephi_queue_latency_ms{window,stat}, facephi_sdk_latency_ms{window,stat}
gauge
Block latency, with stat equal to avg, p50, p95, p99 or max
facephi_total_latency_ms_count{window} / _sum{window} / _bucket{window,le} and their queue and processing equivalents
gauge
Count, sum, and cumulative histogram for each latency series within the window
Exposure notes:
The
facephi_selphid_*series, global totals, and unlabeledsaturationseries declare their type with a# TYPEline. Endpoint, window, and latency series are published without this line; the “Type” column indicates how to interpret them.Classification and alert series always publish all possible values, with
0when the condition is inactive, so they do not appear or disappear between queries. The sample counts forqualityare also published, with0, before the first operation.Series with a count per value (
operation,quality,diagnostic,status) appear when that value is first observed, and summaryfacephi_selphid_quality_score_*series appear when the JSON snapshot includes them.Window series (
{window="1m|5m|15m"}) summarize only requests in that rolling window, so their values may decrease between queries.Timestamps are published as epoch seconds (
*_timestamp_seconds) and are set to0while the snapshot has not recorded that timestamp.Descriptive text (
state.sdk.lastErrorandalerts[].message) is published only in the JSON response.
6.5 Metrics configuration
These parameters are configured at startup, in config.json or using the indicated environment variables, which take precedence. They are not returned by GET /api/v1/selphid/config and cannot be modified at runtime. The metrics_* thresholds only change how the snapshot is classified and which alerts are published; they do not change request processing.
metrics_enabled
FACEPHI_SELPHID_REST_METRICS_ENABLED
boolean
true
Records requests in the traffic, saturation and latencyblocks. With false, no requests are recorded: traffic, latency, usage and the figures for in-flight requests and the queue for saturation are zero
metrics_saturation_queue_p95_ms
FACEPHI_SELPHID_REST_METRICS_SATURATION_QUEUE_P95_MS
integer
250
95th percentile of queue latency over the last minute (ms) above which the queue is considered saturated
metrics_saturation_min_inflight_ratio
FACEPHI_SELPHID_REST_METRICS_SATURATION_MIN_INFLIGHT_RATIO
number
1.0
Fraction of configuredThreads that in-flight requests must exceed for the service to be considered saturated
metrics_error_rate_warning
FACEPHI_SELPHID_REST_METRICS_ERROR_RATE_WARNING
number
0.05
5-minute error rate ( 4xx and 5xxresponses) above which the service is classified as degraded and the alert is triggered HIGH_ERROR_RATE
metrics_idle_rps_threshold
FACEPHI_SELPHID_REST_METRICS_IDLE_RPS_THRESHOLD
number
0.01
Requests per second over the last 15 minutes below which the service is classified as idle
metrics_quality_alert_window_seconds
FACEPHI_SELPHID_REST_METRICS_QUALITY_ALERT_WINDOW_SECONDS
integer
900
Window, in seconds, during which a low-quality sample keeps the alert active LOW_QUALITY. With 0, the alert is deactivated
A metrics_* threshold that cannot be parsed, is negative, or is non-finite is discarded with a log warning: if it comes from an environment variable, the value from config.jsonis used, and if that is also invalid, the default value.
Last updated