faucet.watcher_conf module

Gauge watcher configuration.

class faucet.watcher_conf.WatcherConf(_id, dp_id, conf, prom_client)[source]

Bases: Conf

Stores the state and configuration to monitor a single stat.

Watcher Config

Watchers are configured in the watchers config block in the config for gauge.

The following elements can be configured for each watcher, at the level of /watchers/<watcher name>/:

  • type (string): The type of watcher (IE what stat this watcher monitors). The types are ‘port_state’, ‘port_stats’ or ‘flow_table’.

  • dps (list): A list of dps that should be monitored with this watcher.

  • db (string): The db that will be used to store the data once it is retreived.

  • interval (int): if this watcher requires polling the switch, it will monitor at this interval.

The config for a db should be created in the gauge config file under the dbs config block.

The following elements can be configured for each db, at the level of /dbs/<db name>/:

  • type (string): the type of db. The available types are ‘text’ and ‘influx’ for port_state, ‘text’, ‘influx’and ‘prometheus’ for port_stats and ‘text’ and flow_table.

The following config elements then depend on the type.

For text:
  • file (string): the filename of the file to write output to.

  • path (string): path where files should be written when writing to muiltiple files

  • compress (bool): compress (with gzip) flow_table output while writing it

For influx:
  • influx_db (str): The name of the influxdb database. Defaults to ‘faucet’.

  • influx_host (str): The host where the influxdb is reachable. Defaults to ‘localhost’.

  • influx_port (int): The port that the influxdb host will listen on. Defaults to 8086.

  • influx_user (str): The username for accessing influxdb. Defaults to ‘’.

  • influx_pwd (str): The password for accessing influxdb. Defaults to ‘’.

  • influx_timeout (int): The timeout in seconds for connecting to influxdb. Defaults to 10.

  • influx_retries (int): The number of times to retry connecting to influxdb after failure. Defaults to 3.

For Prometheus:
  • prometheus_port (int): The port used to export prometheus data. Defaults to 9303.

  • prometheus_addr (ip addr str): The address used to export prometheus data. Defaults to ‘’.


Add database config to this watcher.


Add a datapath to this watcher.


Check config at instantiation time for errors, typically via assert.

db_defaults = {'compress': False, 'file': None, 'influx_db': 'faucet', 'influx_host': 'localhost', 'influx_port': 8086, 'influx_pwd': '', 'influx_retries': 3, 'influx_timeout': 10, 'influx_user': '', 'path': None, 'prometheus_addr': '', 'prometheus_port': 9303, 'prometheus_test_thread': False, 'type': None}
db_defaults_types = {'compress': <class 'bool'>, 'file': <class 'str'>, 'influx_db': <class 'str'>, 'influx_host': <class 'str'>, 'influx_port': <class 'int'>, 'influx_pwd': <class 'str'>, 'influx_retries': <class 'int'>, 'influx_timeout': <class 'int'>, 'influx_user': <class 'str'>, 'path': <class 'str'>, 'prometheus_addr': <class 'str'>, 'prometheus_port': <class 'int'>, 'prometheus_test_thread': <class 'bool'>, 'type': <class 'str'>}
defaults: dict = {'all_dps': False, 'db': None, 'db_type': 'text', 'dbs': None, 'dps': None, 'interval': 30, 'name': None, 'type': None}
defaults_types: dict = {'all_dps': <class 'bool'>, 'db': <class 'str'>, 'db_type': <class 'str'>, 'dbs': <class 'list'>, 'dps': <class 'list'>, 'interval': <class 'int'>, 'name': <class 'str'>, 'type': <class 'str'>}