Skip to main content

netscaler_exporter

Overview

dashboard overview

Description

Prometheus exporter for Netscaler (CITRIX ADC)

This exporter collect metrics from netscaler HTTP REST API.

It is a python HTTP server that exposes metrics to http (default port 9247) that can be then scrapped by Prometheus.

This exporter is strongly inspired from citrix-adc-metrics-exporter

It allows you collect several netscalers by adding them to the YAML config file and then specifying a target parameter in Prometheus configuration.

Config: (see conf/netscaler_exporter.yml)

netscalers:
  - host: host.domain
#    port: 443
    user: 'user'
    password: 'password'
#   protocol: https
#   verify_ssl: false
#   timeout: 20
#   keep_session: true # default
#   default_labels:
#     - name: netscaler_specific_data
#       value: my_label
#       proxy:
#         url: http://my.proxy.domain:port/
#         protocol: https

weblisten:
  address: 0.0.0.0
  port: 9259

logger:
  level: info
  facility: syslog

metrics_file: "conf/metrics/*_metrics.yml"

Usage

The exporter may run as a unix command with module installation or as standalone python script without instalation. i

Usage as a system command

the easiest way is to install from pip:

pip3 install --upgrade netscaler_exporter

then you can use the entry point create by the installer of the module in /usr/local/bin/netscaler_exporter or in [venv]/bin/netscaler_exporter for venv context. The recommanded usage is in venv.

Usage as a Python Script

To use the exporter, few packages needs to be installed. This can be done using:

pip3 install -r requirements.txt

Contents of requirements.txt

Prometheus-client>=0.8.0
requests==2.23.0
PyYAML==5.3.1
tenacity==6.2.0
urllib3>=1.25.9
Jinja2>=2.11.2
python-dateutil>=0.6.12
  • Consider, to extract the archiv file in /tmp folder; this will generate a folder /tmp/netscaler_exporter_[version].
  • create a directory where you want, by example /opt/netscaler_exporter_[version],
  • move the /tmp/netscaler_exporter_[version]/netscaler_exporter_package directory to /opt/eeam_exporter_[version]
  • create a command file to launch the exporter in dir /opt/netscaler_exporter_[version]
vi /opt/netscaler_exporter_X.Y.Z/netscaler_exporter_cmd
#!/usr/libexec/platform-python
# -*- coding: utf-8 -*-
import re
import sys
from netscaler_exporter.netscaler_exporter import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
  • Then edit the conf/config.yml file and add your settings.
  • Try your config by executing the command in try mode

example with the default dumy config file:

python3 veeam_exporter_cmd -n -v

exporter command line options

to start the exporter:

./netscaler_exporter &

By default, it will load the file config.yml to perform action.

Detail options
usage: netscaler_exporter_cmd [-h] [-b BASE_PATH] [-c CONFIG_FILE]
                              [-F FILTER_PATH] [-f LOGGER.FACILITY]
                              [-l {error,warning,info,debug}]
                              [-o  METRICS_FILE] [-m  METRIC] [-n]
                              [-t  TARGET] [-w WEB.LISTEN_ADDRESS] [-V] [-v]

collector for Citrix Netscaler.

optional arguments:
  -h, --help            show this help message and exit
  -b BASE_PATH, --base_path BASE_PATH
                        set base directory to find default files.
  -c CONFIG_FILE, --config_file CONFIG_FILE
                        path to config files.
  -F FILTER_PATH, --filter_path FILTER_PATH
                        set filter directory to find filter files.
  -f LOGGER.FACILITY, --logger.facility LOGGER.FACILITY
                        logger facility (syslog or file path).
  -l {error,warning,info,debug}, --logger.level {error,warning,info,debug}
                        logger level.
  -o  METRICS_FILE, --metrics_file METRICS_FILE
                        collect the metrics from the specified file instead of
                        config.
  -m  METRIC, --metric METRIC
                        collect only the specified metric name from the
                        metrics_file.
  -n , --dry_mode       collect the metrics then exit; display results to
                        stdout.
  -t  TARGET, --target TARGET
                        In dry_mode collect metrics on specified target.i
                        Default first from config file.
  -w WEB.LISTEN_ADDRESS, --web.listen-address WEB.LISTEN_ADDRESS
                        Address to listen on for web interface and telemetry.
  -V, --version         display program version and exit..
  -v , --verbose        verbose mode; display log message to stdout.

To test your configuration you can launch the exporter in dry_mode:

./netscaler_exporter -v -n -t host.domain

This command will try to connect to the 'host.domain' netscaler with parameters specified in config.yml, exposes the collected metrics, and eventually the warning or errors, then exits.

Prometheus config

Since several netscalers can be set in the exporter, Prometheus addresses each server by adding a target parameter in the url. The "target" must be the same (lexically) that in exporter config file.

  - job_name: "citrix_netscaler"
    scrape_interval: 30s
    scrape_timeout: 20s
    metrics_path: /metrics

    static_configs:
      - targets: [ netscalerhost.domain ]
        labels:
          environment: "PROD"
      - targets: [ netscalerhost2.domain]
        labels:
          environment: "PROD"

#    file_sd_configs:
#      - files: [ "/etc/prometheus/citrix_exp/*.yml" ]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: "netscaler-exporter-hostname.domain:9258"  # The netscaler exporter's real hostname.

Metrics

The collected metrics are defined in separeted files positionned in the folder conf/metrics. All values, computations, labels are defined in the metrics files, meaning that the exporter doesn't nothing internally on values. The configuration fully drive how values are rendered.

Currently collected metrics are:

All metrics are defined in the configuration files (conf/metrics/*.yml). You can retrive all metric names here. Most of them have help text too.

STATS NS nitro name
LB vserver stats "lbvserver"
CS vserver stats "csvserver"
HTTP stats "protocolhttp"
TCP stats "protocoltcp"
UDP stats "protocoludp"
IP stats "protocolip"
Interface stats "Interface" (capital 'i')
Service stats "service"
Service group stats "services"
Bandwidth Capacity stats "nscapacity"
SSL stats "ssl"
SSL Certicates stats "sslcertkey"
SSL vserver stats "sslvserver"
System info stats "system"
System memory stats "systemmemory"
System cpu stats "systemcpu"
High Availability stats "hanode.yml"
AAA stats "aaa"
ADC Probe success "1" if login is successful, else "0"

Extending metrics

Exported metrics, are defined in the YAML config files. The value can use Jinja2 templating language. The format of the configuration is inspired from Ansible tasks representation. So a metric configuration file, consists in a list of actions to perform.

There are five possible actions:

  • url: to collect metrics from HTTP API
  • set_fact: to assign value to variables
  • actions: to perform a list of (sub-)actions
  • metrics: to define metrics to expose/return to Prometheus
  • debug: to display debug text to logger.

All actions have default "attributes":

  • name: the name of action or metric counter for metrics action.
  • vars: to set vars to global symbols' table.
  • with_items: to loop on current action with a list of items.
  • loop_var: to set the name of the variable that will receive the current value in the loop. Default is 'item'.
  • when: a list of condition (and) that must be check and be true to perform the action.

The "attributes" are analyzed in the order specified in previous table; it means that you can't use "item" var (obtained from 'with_items' directive) in the vars section because it is not yet defined when the 'vars' section is evaluated. If you need that feature, you will have to consider 'with_items' in an 'actions' section (see metrics/backup_jobs_sessions_metrics.yml).

action parameter description remark
url   a string that's representing the entity to collect without '/nitro/v1' http://host.domain:port/nitro/v1**[url]**. e.g.: /stat/system
  var_name the name ofthe variable to store the results. Default is '_root' meaning that the resulting JSON object is directly store in symbols table.  
       
set_fact   list of variable to define  
  var_name: value  
       
metrics   define the list of metrics to expose
  metric_prefix a prefix to add to all metric name final name will be [metric_prefix]_[metric_name]
'a metric' name the name of the metric
  help the help message added to the metric (and displayed in grafana explorer)
  type 'gauge' or 'counter' the type of the prometheus metric  
  value the numeric value itself  
  labels a list of name value pairs to qualify the metric  

A metric configuration file is so at minimum, an action containing list of two actions, one for collecting values on netscaler with 'url', one to define the resulting metric for prometheusi with 'metrics':

example:

---
- name: my_custom_metric
  actions:
    # first action
    - name: collect elements 
      url: /stat/system
    # second action
    - name: proceed elements
      metric_prefix: citrixadc_custmetric
      metrics:
        - name: cpu_number
          help: constant number of cpu for appliance
          type: counter
          value: "{{ system.numcpus }}"

... 

Metadata

Release files for netscaler-exporter 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netscaler-exporter 1.1.1
File Size Uploaded Provenance
netscaler_exporter-1.1.1.tar.gz 341.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for netscaler-exporter 1.1.1
File Interpreter ABI Platform
netscaler_exporter-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 382.9 kB

Release files / netscaler_exporter-1.1.1.tar.gz

Download URL netscaler_exporter-1.1.1.tar.gz
Size 341.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3adabc7b9eb96af59d7db6497c95afdb0b0be47a6191fc08a3872b90cfb62319
BLAKE2b-256 checksum
How to use checksums
f3aa4e4f32b7f52b4cb02f58cdf54c29a946d3a8500724d52d4a840191372ba6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release files / netscaler_exporter-1.1.1-py3-none-any.whl

Download URL netscaler_exporter-1.1.1-py3-none-any.whl
Size 41.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9073b9db95a43b9f535364c4246481deb802a9b291b23a1b580e294f938ab7e
BLAKE2b-256 checksum
How to use checksums
62e65712d232159097991a6173a0e731ac6d6dc277346d7abda44b67b280384a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Security for netscaler-exporter 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page