Custom metrics configuration for NetScaler CPX using ConfigMap
You can provide custom metrics configuration JSON files to a NetScaler CPX™ instance in Kubernetes using ConfigMap. This allows you to add custom metrics schema files without overwriting the default metrics configuration files (
schema.json and reference_schema.json) that include CPX.
During startup, the NetScaler CPX instance places the default metrics configuration files in the
/var/metrics_conf directory. If you mount a ConfigMap at /cpx/custom_metrics_conf, CPX validates each JSON file and copies valid files into /var/metrics_conf alongside the defaults.
Notes:
-
Custom JSON files must contain valid JSON. Invalid files are skipped during startup, and an error is logged in
boot.log. -
Default files (
schema.json,reference_schema.json) are always placed first. -
Custom files with the same name as a default file override the default file.
Configure custom metrics
You can configure custom metrics for NetScaler CPX by creating a ConfigMap and deploying the NetScaler CPX instance with the ConfigMap mounted.
To configure by using the CLI
Create the custom metrics configuration JSON files that you want to provide to the NetScaler CPX instance. The following is a sample custom configuration file:
{
"counter": "http_requests_total",
"label": "method",
"description": "Total HTTP requests by method"
}
Create a ConfigMap from the files using the
kubectl create configmap command. For example, to create a ConfigMap named custom-metrics-conf based on the configuration file custom_schema.json:
kubectl create configmap custom-metrics-conf --from-file=custom_schema.json=./custom_schema.json
View the created ConfigMap using the
kubectl get configmap command.
kubectl get configmap custom-metrics-conf -o yaml
The following example shows sample output:
apiVersion: v1
data:
custom_schema.json: |
{
"counter": "http_requests_total",
"label": "method",
"description": "Total HTTP requests by method"
}
kind: ConfigMap
metadata:
creationTimestamp: 2026-05-14T06:26:50Z
name: custom-metrics-conf
namespace: default
resourceVersion: "8865149"
uid: c1c7cb5b-ea05-11e7-914a-926745c10b02
To configure using a YAML file
Specify the created ConfigMap,
custom-metrics-conf, in the YAML file used to deploy the NetScaler CPX instance. The following sample configuration shows how to include the ConfigMap in the deployment YAML:
apiVersion: v1
kind: Pod
metadata:
name: cpx-1
labels:
app: cpx-daemon
annotations:
NETSCALER_AS_APP: "True"
spec:
containers:
- name: cpx
image: "quay.io/netscaler/netscaler-cpx:14.1-72.56"
securityContext:
privileged: true
volumeMounts:
- name: config-volume
mountPath: /cpx/bootup_conf
- name: custom-metrics-volume
mountPath: /cpx/custom_metrics_conf
env:
- name: "EULA"
value: "yes"
imagePullPolicy: IfNotPresent
volumes:
- name: config-volume
configMap:
name: cpx-config
- name: custom-metrics-volume
configMap:
name: custom-metrics-conf
Deploy the NetScaler CPX instance. Once the instance deploys and starts, the default metrics configuration files (
schema.json and reference_schema.json) are placed in /var/metrics_conf. The custom JSON files from the ConfigMap mounted at /cpx/custom_metrics_conf are validated and copied into /var/metrics_conf.