Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: changelog doc #2453

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions cmd/poller/plugin/changelog/change_log_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,31 @@ func getChangeLogConfig(parentParams *node.Node, overwriteConfig []byte, logger
)
object := parentParams.GetChildS("object").GetContentS()

useDefault := true

if len(overwriteConfig) > 0 {
entry, err = preprocessOverwrite(object, overwriteConfig)
if err != nil {
logger.Warn().Err(err).Str("template", string(overwriteConfig)).Msg("failed to parse changelog dsl. Trying default")
} else {
return entry, nil
useDefault = false
}
}

err = yaml.Unmarshal([]byte(defaultChangeLogTemplate), &config)
if err != nil {
return Entry{}, err
if useDefault {
err = yaml.Unmarshal([]byte(defaultChangeLogTemplate), &config)
if err != nil {
return Entry{}, err
}
i := slices.IndexFunc(config.ChangeLogs, func(entry Entry) bool {
return entry.Object == object
})
if i == -1 {
return Entry{}, nil
}
entry = config.ChangeLogs[i]
}

i := slices.IndexFunc(config.ChangeLogs, func(entry Entry) bool {
return entry.Object == object
})
if i == -1 {
return Entry{}, nil
}
entry = config.ChangeLogs[i]
// populate publish_labels if they are empty
if entry.PublishLabels == nil {
if exportOption := parentParams.GetChildS("export_options"); exportOption != nil {
Expand Down
114 changes: 113 additions & 1 deletion docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,4 +631,116 @@ compute_metric:
# inode_used_percent = inode_files_used / inode_files_total * 100
```

# ChangeLog
# ChangeLog Plugin

The ChangeLog plugin is a feature of Harvest, designed to detect and track changes related to the creation, modification, and deletion of an object. By default, it supports volume, svm, and node objects. However, its functionality can be extended to track changes in any other objects by making relevant changes in the template.

Please note that the ChangeLog plugin requires the `uuid` label, which is unique, to be collected by the template. Without the `uuid` label, the plugin will not function.

The ChangeLog feature only detects changes when Harvest is up and running. It does not detect any changes that occur when Harvest is down. Additionally, the plugin currently does not detect changes in metric values.

## Enabling the Plugin

The plugin can be enabled in the templates under the plugins section.

For volume, svm, and node objects, you can enable the plugin with the following configuration:

```yaml
plugins:
- ChangeLog
```

For other objects, you need to specify the labels to track in the plugin configuration. These labels should be relevant to the object you want to track. If these labels are not specified in template, the plugin will not be able to track changes for the object.

Here's an example of how to enable the plugin for an aggregate object:

```yaml
plugins:
- ChangeLog:
track:
- aggr
- node
- state
```

In the above configuration, the plugin will track changes in the `aggr`, `node`, and `state` labels for the aggregate object.

## Default Tracking for svm, node, volume

By default, the plugin tracks changes in the following labels for svm, node, and volume objects:

- svm: svm, state, type, anti_ransomware_state
- node: node, location, healthy
- volume: node, volume, svm, style, type, aggr, state, status

For any other objects, defaults are not available and need to be defined in the plugin.

These default settings can be overwritten as needed in the relevant templates. For instance, if you want to track `junction_path` labels for Volume, you can overwrite this in the volume template.

```yaml
plugins:
- ChangeLog:
- track:
- node
- volume
- svm
- style
- type
- aggr
- state
- status
- junction_path
```

## Change Types and Metrics

The ChangeLog plugin publishes a metric with various labels providing detailed information about the change when an object is created, modified, or deleted.

### Object Creation

When a new object is created, the ChangeLog plugin will publish a metric with the following labels:

- The name of the ONTAP object that was changed (object)
- The type of change that was made (op)
- The timestamp when Harvest Poller captured the change (Metric Value)

Example of metric shape for object creation:

```
change_log{aggr="umeng_aff300_aggr2", cluster="umeng-aff300-01-02", datacenter="u2", index="0", instance="localhost:12993", job="prometheus", node="umeng-aff300-01", object="volume", op="create", style="flexvol", svm="harvest", volume="harvest_demo"} 1698735558
```

### Object Modification

When an existing object is modified, the ChangeLog plugin will publish a metric with the following labels:

- The name of the ONTAP object that was changed (object)
- The type of change that was made (op)
- The property of the object which was modified (Track)
- The new value of the object after the change was made (New Value)
- The previous value of the object before the change was made (Old Value)
- The timestamp when Harvest Poller captured the change (Metric Value)

Example of metric shape for object modification:

```
change_log{aggr="umeng_aff300_aggr2", cluster="umeng-aff300-01-02", datacenter="u2", index="1", instance="localhost:12993", job="prometheus", new_value="offline", node="umeng-aff300-01", object="volume", old_value="online", op="update", style="flexvol", svm="harvest", track="state", volume="harvest_demo"} 1698735677
```

### Object Deletion

When an object is deleted, the ChangeLog plugin will publish a metric with the following labels:

- The name of the ONTAP object that was changed (object)
- The type of change that was made (op)
- The timestamp when Harvest Poller captured the change (Metric Value)

Example of metric shape for object deletion:

```
change_log{aggr="umeng_aff300_aggr2", cluster="umeng-aff300-01-02", datacenter="u2", index="2", instance="localhost:12993", job="prometheus", node="umeng-aff300-01", object="volume", op="delete", style="flexvol", svm="harvest", volume="harvest_demo"} 1698735708
```

## Viewing the Metrics

You can view the metrics published by the ChangeLog plugin in the `ChangeLog Monitor` dashboard in `Grafana`. This dashboard provides a visual representation of the changes tracked by the plugin for volume, svm, and node objects.
Loading