Skip to content

Commit

Permalink
Add ElasticSearch tags to root element instaed of a dictionary-field
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianOpeni committed Sep 26, 2024
1 parent 3b3b435 commit c661ba2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/09-object-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1219,8 +1219,8 @@ Configuration Attributes:
password | String | **Optional.** Basic auth password if Elasticsearch is hidden behind an HTTP proxy.
enable\_tls | Boolean | **Optional.** Whether to use a TLS stream. Defaults to `false`. Requires an HTTP proxy.
insecure\_noverify | Boolean | **Optional.** Disable TLS peer verification.
host\_tags\_template | Dictionary | **Optional.** Allows to apply additional tags to the Elasticsearch host entries. They will be added under `tags`.
service\_tags\_template | Dictionary | **Optional.** Allows to apply additional tags to the Elasticsearch service entries. They will be added under `tags`.
host\_tags\_template | Dictionary | **Optional.** Allows to apply additional tags to the Elasticsearch host entries.
service\_tags\_template | Dictionary | **Optional.** Allows to apply additional tags to the Elasticsearch service entries.
ca\_path | String | **Optional.** Path to CA certificate to validate the remote host. Requires `enable_tls` set to `true`.
cert\_path | String | **Optional.** Path to host certificate to present to the remote host for mutual verification. Requires `enable_tls` set to `true`.
key\_path | String | **Optional.** Path to host key to accompany the cert\_path. Requires `enable_tls` set to `true`.
Expand Down
6 changes: 3 additions & 3 deletions doc/14-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,9 @@ host_tags_template = {
```
Will in addition to the above mentioned lines also contain:
```
tags.os_name = "Linux"
tags.custom_label = "A Custom Label"
tags.a_list_of_items = [ "foo", "bar" ]
os_name = "Linux"
custom_label = "A Custom Label"
a_list_of_items = [ "foo", "bar" ]
```

#### Elasticsearch in Cluster HA Zones <a id="elasticsearch-writer-cluster-ha"></a>
Expand Down
4 changes: 1 addition & 3 deletions lib/perfdata/elasticsearchwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,15 @@ void ElasticsearchWriter::AddTemplateTags(const Dictionary::Ptr& fields, const C
resolvers.emplace_back("service", service);
}

Dictionary::Ptr tags = new Dictionary();
ObjectLock olock(tmpl);
for (const Dictionary::Pair& pair : tmpl) {
String missingMacro;
Value value = MacroProcessor::ResolveMacros(pair.second, resolvers, cr, &missingMacro);

if (missingMacro.IsEmpty()) {
tags->Set(pair.first, value);
fields->Set(pair.first, value);
}
}
fields->Set("tags", tags);
}
}

Expand Down

0 comments on commit c661ba2

Please sign in to comment.