Skip to content

File Discovery

gnmic is able to watch changes happening to a file carrying the gNMI targets configuration.


A file targets loader can be configured in a couple of ways:

  • using the --targets-file flag:
gnmic --targets-file ./targets-config.yaml subscribe
  • using the main configuration file:
  type: file
  # path to the file
  file: ./targets-config.yaml
  # watch interval at which the file
  # is read again to determine if a target was added or deleted.
  interval: 5s

The --targets-file flag takes precedence over the loader configuration section.

The targets file can be either a YAML or a JSON file (identified by its extension json, yaml or yml), and follows the same format as the main configuration file targets section. See here

    username: admin
    insecure: true
    username: admin
    "": {
        "username": "admin",
        "insecure": true
     "": {
        "username": "admin",
     "": {},
     "": {},
     "": {}

Just like the targets in the main configuration file, the missing configuration fields get filled with the global flags, the ENV variables, the config file main section and then the default values.