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 Scenarios
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
Container discovery control involves two key parameters: inclusion and exclusion. These parameters accept a single input rule value each, allowing you to specify inclusion and exclusion criteria. The available rule values are:
namespace
: Applies specifically to Kubernetes and its derivatives. It enables you to include or exclude containers based on their namespace.image_name
: Allows you to include or exclude containers based on their image name.container_name
: You can Include or exclude containers based on their container name.
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:.*" |
Rule Specification
Rule values have the following general format. You can specify multiple rules, separated by commas. Here are the supported keys:
namespace:<namespace_name1>, namespace:<namespace_name2>, image_name:<image_name1>, image_name:<image_name2>, container_name:<container_name1>, container_name:<container_name2>
You can use regex for inclusion and exclusion values. By default, the string is checked for inclusion, so you don’t need to provide the full string when specifying a value.
Install Virtual Machine Rule Specification
During agent installation, use the following -E
and -I
options to 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 disabled 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 |