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

Small improvements on the azure module #13859

Merged
merged 13 commits into from
Oct 9, 2019
Merged

Conversation

narph
Copy link
Contributor

@narph narph commented Oct 1, 2019

  • Work on validation and adding conditions
  • Small work on azure docs

@narph narph requested a review from a team as a code owner October 1, 2019 11:04
@narph narph self-assigned this Oct 1, 2019
@narph narph added Team:Integrations Label for the Integrations team [zube]: In Progress Metricbeat Metricbeat labels Oct 1, 2019
@narph narph assigned jsoriano and unassigned jsoriano Oct 3, 2019
@narph narph requested a review from jsoriano October 3, 2019 07:59
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some suggestions about documentation, and please review the changelog, I think we are missing an entry for the Azure module.

@@ -386,6 +386,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add support for NATS version 2. {pull}13601[13601]
- Add `docker.cpu.*.norm.pct` metrics for `cpu` metricset of Docker Metricbeat module. {pull}13695[13695]
- Add `instance` label by default when using Prometheus collector. {pull}13737[13737]
- Add small improvements in the azure module (validation, doc update) {pull}13859[13859]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, we should have an entry about the new Azure module, but I think we forgot it in #13196
As the module is not released yet we wouldn't need this new entry.
Could you replace this one with one about adding the module itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added both entries in the list, is there a reason the second one should be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@narph My understanding is changelog is user facing. Since this is not released yet, they don't need to know how many PRs we spent to add the initial pr, the improvements, the docs and etc. But I agree with Jaime, the new module needs to be an entry by itself 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have merged the 2 PRs in one comment line

metricbeat/docs/modules/azure.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/azure.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/azure.asciidoc Outdated Show resolved Hide resolved

`tenant_id` - The unique identifier of the Azure Active Directory instance

Users can use the azure credentials keys if configured `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`, `AZURE_SUBSCRIPTION_ID`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part could be moved to some other file so it can be reused in other features that need to authenticate with Azure AD in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have cleaned up the documentation and touched on your findings as well. At the moment this is the only place where it will be used. Do you have any recommendations where the information regarding credentials should be moved?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some shared doc files in libbeat/docs/shared-*. We can wait to move this content to a shared file when we need it in any case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

metricbeat/docs/modules/azure.asciidoc Outdated Show resolved Hide resolved
metricbeat/docs/modules/azure.asciidoc Outdated Show resolved Hide resolved
@narph narph requested a review from jsoriano October 3, 2019 13:04

Costs: Metric queries are charged based on the number of standard API calls. More information on pricing here https://azure.microsoft.com/id-id/pricing/details/monitor/.

Authentication: we are handling authentication on our side (creating/renewing the authentication token), so we advise users to use dedicated credentials for metricbeat only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, are there a set of permissions user need to give this account in order for azure module to collect the metrics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More information on the authentication and the steps to require a service principal are found higher in the docs.asciidoc in the === Module-specific configuration notes.
I have just added the link to the RBAC as well, users will need to assign a role that allows them to read monitoring data, minimum effort would be "Monitoring Reader"

CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
@@ -32,8 +35,14 @@ func mapMetric(client *azure.Client, metric azure.MetricConfig, resource resourc
if len(*metricDefinitions.Value) == 0 {
return nil, errors.Errorf("no metric definitions were found for resource %s and namespace %s.", *resource.ID, *namespace.Properties.MetricNamespaceName)
}
var filteredMetricDefinitions []insights.MetricDefinition
for _, metricDefinition := range *metricDefinitions.Value {
if (metricDefinition.Name.LocalizedValue != nil && !strings.Contains(*metricDefinition.Name.LocalizedValue, "(Deprecated)")) || metricDefinition.Name.LocalizedValue == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be simpler and equivalent

Suggested change
if (metricDefinition.Name.LocalizedValue != nil && !strings.Contains(*metricDefinition.Name.LocalizedValue, "(Deprecated)")) || metricDefinition.Name.LocalizedValue == nil {
if metricDefinition.Name.LocalizedValue == nil || !strings.Contains(*metricDefinition.Name.LocalizedValue, "(Deprecated)")) {

Btw, why are we filtering out deprecated values?

Can the use of "localized" values be a problem if languages different to English are used?

Copy link
Contributor Author

@narph narph Oct 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the API will not return the "deprecated" message although it will do so for the "preview". Non the less, testing different languages for the metric localized name, indeed should translate the "deprecated" word as well (https://docs.microsoft.com/nl-NL/azure/azure-monitor/platform/metrics-supported#microsoftcomputevirtualmachines , for nl version "afgeschaft"). I have removed the entire condition in both places.

@narph narph requested a review from jsoriano October 7, 2019 12:53
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of extra small suggestions

}

//validate config based on metricset
switch base.Name() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be metricsetName?

Suggested change
switch base.Name() {
switch metricsetName {


// FetchValues methods implements the data gathering and data conversion to the right metricset
func (m *MetricSet) FetchValues(fn mapMetric, report mb.ReporterV2) error {
err := m.Client.InitResources(fn, report)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If fn would be an attribute of the metricset I think that this FetchValues could be the Fetch method of all derived metricsets.

Suggested change
err := m.Client.InitResources(fn, report)
err := m.Client.InitResources(m.mapMetricFn, report)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the suggestion, I have made the changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@narph narph merged commit 1fb41ea into elastic:master Oct 9, 2019
@narph narph deleted the metricbeat-azure branch October 9, 2019 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metricbeat Metricbeat Team:Integrations Label for the Integrations team v7.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants