Log File Example
This example demonstrates how to create a dynamic attribute based on a device log file.
The rule will extract if the image name from the device’s show version
and set a dynamic attribute.
Log File Configuration
---
ipfabric:
base_url: null # Recommended to use Environment Variables
auth: null
timeout: 5
verify: true
snapshot_id: $last
dry_run: true
update_snapshot: true
default_config:
overwrite: true # Defaults to false to avoid overwriting existing attributes
filters:
- value: cisco
operator: eq
column: vendor
- value: ios
operator: eq
column: family
inventory:
report_columns:
- loginIp
default: null
rules:
- name: Image Name
attribute: IMAGE_NAME
value:
regex:
pattern: ^Cisco IOS Software, .* Software \(([^(]*)\),
group: 1
flags:
- IGNORECASE
- MULTILINE
config: log
no_config_value: IPF Unsupported
null_value: Unknown
Example Text:
d5xr01#show version
Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.6(2)T, RELEASE SOFTWARE (fc2)
The above configuration will create a dynamic attribute named IMAGE_NAME
and set its value based on the extracted image name from the log file (VIOS-ADVENTERPRISEK9-M
).
If the pattern is not found, it will set the value to Unknown
.
If the device does not support log file extraction, it will set the value to IPF Unsupported
.