By default, both containerized and bare metal agents discover all containers. You can change the default behavior in the YAML file to specify which containers to exclude from discovery.
Inclusion and exclusion use cases
The following figure shows example container filtering scenarios for a cluster that has three namespaces:
- logging
- monitoring
- testing
Use case | Inclusion | Exclusion/th> |
---|---|---|
Monitor single namespace monitoring | namespace:monitoring | namespace:.* |
Monitor everything except namespace logging | namespace:logging | |
Do not monitor namespaces monitoring and logging | namespace:monitoring namespace:logging | |
Monitor only one Container with name logger-beta-abcde in namespace logging | container_name:logger-beta-abcde | namespace:logging |
Monitor only a single container with image name agent | image_name: agent | namespace:monitoring namespace:logging namespace:testing or namespace:.* |
Do not monitor containers with name starting with log | container_name: log.* or container_name:log | |
Do not monitor containers with image name starting with log | image_name:log.* or image_name:log |
Enable Container Discovery
Two keys control container inclusion or exclusion:
Key | Description |
---|---|
INCLUDE_CONTAINER | Criteria for including containers. Example to include container by image name:name: INCLUDE_CONTAINER value: "image_name:lighttpd2" |
EXCLUDE_CONTAINER | Criteria for excluding containers. Example to exclude containers by namespace:name: EXCLUDE_CONTAINER value: "namespace:.*" |
Both keys accept one of the following single input rule values for specifying inclusion and exclusion:
namespace
, which applies only to Kubernetes and its spinsimage_name
container_name
Rule specification
Rule values have the following general format:
namespace:<namespace_name1>, namespace:<namespace_name2>, image_name:<image_name1>, image_name:<image_name2>, container_name:<container_name1>, container_name:<container_name2>
Rules are comma-delimited and must be key:value pairs.
Regex is supported when specifying inclusion and exclusion values. By default, the string is checked for containing the value so the full string does not need to be provided when specifying a value.
Install and virtual machine rule specification
During agent installation, use the following -E
and -I
options to the configure binary. For example:
sudo /opt/opsramp/agent/bin/configure -K T2fTf...4m9c -S UGWjhy...mKPnRuM -s <hostServer> -E "namespace:testing" -I "image_name:lighttpd2"
For a virtual machine these options are in the configuration.properties
Misc
section. For example:
exclude_container = namespace:.*
include_container = image_name:lighttpd2
Disable Container Discovery
To disable all container discovery, set the disable variable in the containers
env
section of the agent YAML file:
name: DISABLE_CONTAINER_DISCOVERY
value: "TRUE"
Inclusion and exclusion setting results
Inclusion | Exclusion | Result |
---|---|---|
Not set | Not set | All containers discovered |
Some filter | Not set | All containers discovered |
Not Set | Some filter | All containers except those that match the exclusion filter |
Some filter | Some filter | All containers except those that match the exclusion filter, plus excluded containers that match the inclusion filter |