Package: veeam-exporter
veeam_exporterOverviewDescriptionPrometheus exporter for Veeam Entreprise ManagerThis exporter collects metrics from Veeam Enterprise Manager HTTP API.It is a python HTTP server that exposes metrics to http (default port 9247) that can be then scrapped by Prometheus.Several Veeam server can be polled by adding them to the YAML config file, by adding a host section:Config: (see config.yml)veeams:-host:host.domainport:9398user:'user'password:'password'#   protocol: https#   verify_ssl: false#   timeout: 20#   keep_session: true # default#   default_labels:#     - name: veeam_em#       value: my_veeam_em_server.domain#       proxy:#         url: http://my.proxy.domain:port/#         protocol: httpsweblisten:address:0.0.0.0port:9247logger:level:infofacility:syslogmetrics_file:"conf/metrics/*_metrics.yml"UsageThe exporter may run as a unix command with module installation or as standalone python script without instalation.Usage as a system commandthe easiest way is to install from pip:pip3install--upgradeveeam_exporterthen you can use the entry point, createc by the installer of the module in /usr/local/bin/veeam_exporter or in [venv]/bin/veeam_exporter for venv context.
The recommanded usage is in venv.Usage as a Python ScriptTo use the exporter, few packages needs to be installed. This can be done using:pip3install-rpip_requirements.txtContents of requirements.txtPrometheus-client>=0.8.0requests==2.23.0PyYAML==5.3.1tenacity==6.2.0urllib3>=1.25.9Jinja2>=2.11.2python-dateutil>=0.6.12Consider, to extract the archiv file in /tmp folder; this will generate a folder /tmp/veeam_exporter_[version].create a directory where you want, by example /opt/veeam_exporter_[version],move the /tmp/veeam_exporter_[version]/veeam_exporter_package directory to /opt/eeam_exporter_[version]create a command file to launch the exporter in dir /opt/veeam_exporter_[version]vi/opt/veeam_exporter_X.Y.Z/veeam_exporter_cmd#!/usr/libexec/platform-python# -*- coding: utf-8 -*-importre
importsys
fromveeam_exporter.veeam_exporterimportmainif__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 modeexample with the default dummy config file:python3veeam_exporter_cmd-n-v
veeam_exporter[647132]:level=INFO-veeam_exporter1.0.3starting....
veeam_exporter[647132]:level=DEBUG-configis{'veeams':[{'host':'host.domaine','port':9398,'user':'user','password':'password','verify_ssl':False,'timeout':20}],'weblisten':{'address':'0.0.0.0','port':9247},'logger':{'level':'info','facility':'syslog'},'metrics_file':'conf/metrics/*_metrics.yml'}veeam_exporter[647132]:level=ERROR-ConnectionException:Hosthost.domaine:HTTPSConnectionPool(host='host.domaine',port=9398):Maxretriesexceededwithurl:/api/sessionMngr/?v=latest(CausedbyNewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa9e4eab9b0>: Failed to establish a new connection: [Errno -2] Name or service not known',))veeam_exporter[647132]:level=DEBUG-# HELP veeam_em_up probe success  login status: 0 Down / 1 Upveeam_exporter[647132]:level=DEBUG-# TYPE veeam_em_up gaugeveeam_exporter[647132]:level=DEBUG-veeam_em_up0.0
veeam_exporter[647132]:level=INFO-veeam_exporter1.0.3stopped.exporter command line optionsto start the exporter:./veeam_exporter&By default, it will load the file config.yml to perform action.Detail optionsUsage:veeam_exporter[-h][-bBASE_PATH][-cCONFIG_FILE][-fLOGGER.FACILITY][-l{error,warning,info,debug}][-oMETRICS_FILE][-mMETRIC][-n][-tTARGET][-wWEB.LISTEN_ADDRESS][-V][-v]collectorforveeamserver.

optionalarguments:-h,--helpshowthishelpmessageandexit-bBASE_PATH,--base_pathBASE_PATHsetbasedirectorytofinddefaultfiles.-cCONFIG_FILE,--config_fileCONFIG_FILEpathtoconfigfiles.-fLOGGER.FACILITY,--logger.facilityLOGGER.FACILITYloggerfacility(syslogorfilepath).-l{error,warning,info,debug},--logger.level{error,warning,info,debug}loggerlevel.-oMETRICS_FILE,--metrics_fileMETRICS_FILEcollectthemetricsfromthespecifiedfileinsteadofconfig.-mMETRIC,--metricMETRICcollectonlythespecifiedmetricnamefromthemetrics_file.-n,--dry_modecollectthemetricsthenexit;displayresultstostdout.-tTARGET,--targetTARGETIndry_modecollectmetricsonspecifiedtarget.iDefaultfirstfromconfigfile.-wWEB.LISTEN_ADDRESS,--web.listen-addressWEB.LISTEN_ADDRESSAddresstolistenonforwebinterfaceandtelemetry.-V,--versiondisplayprogramversionandexit..-v,--verboseverbosemode;displaylogmessagetostdout.To test your configuration you can launch the exporter in dry_mode:./veeam_exporter-v-n-thost.domainThis command will try to connect to the 'host.domain' veeam server with parameters specified in config.yml, expose the collected metrics, and eventually the warning or errors, then exits.Prometheus configSince several veeam servers 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:"veeam"scrape_interval:120sscrape_timeout:60smetrics_path:/metricsstatic_configs:-targets:[veeamhost.domain]labels:environment:"PROD"#    file_sd_configs:#      - files: [ "/etc/prometheus/veeam_exp/*.yml" ]relabel_configs:-source_labels:[__address__]target_label:__param_target-source_labels:[__param_target]target_label:instance-target_label:__address__replacement:"veeam-exporter-hostname.domain:9247"# The veeam exporter's real hostname.MetricsThe collected metrics are defined in separeted files positionned the folder conf/metrics.
All Values, computations, labels are defined in the metrics files, meaning that the exporter does nothing internally on values. The configuration fully drives how values are rendered.Collected MetricsAll metrics are defined in the configuration file (conf/metrics/*.yml). You can retrive all metric names here. Most of them have help text too.filedomainmetricsveeam_overview_metrics.ymlgeneral resultscount by type "backup", "proxy", "repository", "scheduled_jobs", "successful_vms", "warning_vms"vm_overview_metrics.ymlgeneral vm resultsVMs count by protection type "protected","backedup","replicated","restore_points"VMs total size in bytes by type "full_backup_points", "incremental_backup_points", "replica_restore_points", "source_vms"percent of sucessful backup of VMsrepositories_metrics.ymlrepositoriestotal and free size and in bytes of each repository by name and typejobs_overview_metrics.ymljobs genericsvarious count of job types "running", "scheduled", "scheduled_backup" "scheduled_replica_jobs_count"total number of job runs by type "total", "successfull", "warning", "failed"max duration for job by type and name of longuestbackup_agent_metrics.ymlbackup agentbackup agent status 1 Online / 2 Offline labeled by nae , type and versionbackup_servers_metrics.ymlbackup serversconfig of each backup server labeled by name, description, port, version: no value collect (1 returned)backup_jobs_sessions_metrics.ymlbackup jobs runslast backup job run info state, duration, retries labeled by backup server, jobname, jobtypevm_backup_jobs_sessions_metrics.ymlvm backup jobs runslast vm backup job runs info state, duration, retries, total_bytes labeled by backup server, jobname, vmname, taskname, messageExtending metricsExported metrics, are defined the YAML config file. The value can use Jinja2 templating language. The format of the configuration is inspired from Ansible task representation.
So a metric configuration file, consists in a list of action to perform.There are five possible actions:url: to collect metrics from HTTP APIset_fact: to assign vlaue to variablesactions: to perform a list of (sub-)actionsmetrics: to define metrics to expose/return to Prometheusdebug: 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).actionparameterdescriptionremarkurla string that's representing the entity to collect without '/api'http://host.domain:port/api**[url]**. e.g.: /reports/summary/overviewvar_namethe name of the variable to store the results. Default is '_root' meaning that the resulting JSON object is directly store in symbols table.set_factlist of variable to definevar_name: valuemetricsdefine the list of metrics to exposemetric_prefixa prefix to add to all metric namefinal name will be [metric_prefix]_[metric_name]'a metric'namethe name of the metrichelpthe help message added to the metric (and displayed in grafana explorer)type 'gauge' or 'counter'the type of the prometheus metricvaluethe numeric value itselflabelsa list of name value pairs to qualify the metric