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

Add mapping for munin and options to override service type and name #10322

Merged
merged 13 commits into from
Jan 31, 2019

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Jan 24, 2019

Make munin module more future-proof in its way to GA by adding a more strict
field mapping and name validation, and options to override ECS fields for
service type and name.

Changes here:

  • All munin metrics moved to munin.metrics, this way we can add more
    munin subfields in the future if needed.
  • An event is generated per plugin now.
  • Everything in munin.metrics.* is expected to be a numeric metric.

@jsoriano jsoriano added module discuss Issue needs further discussion. Metricbeat Metricbeat Team:Integrations Label for the Integrations team labels Jan 24, 2019
@jsoriano jsoriano self-assigned this Jan 24, 2019
@jsoriano jsoriano requested review from a team as code owners January 24, 2019 15:25
@jsoriano
Copy link
Member Author

jenkins, test this again please

@ruflin
Copy link
Member

ruflin commented Jan 25, 2019

If we go with munin.metrics we would have it very similar to what we do with Prometheus. We could remove the namespace option. Instead we would introduce configuration of service.name and service.type. for filtering per service. Or even have namespace as a config option but it does not change the metric prefix.

Could it happen that 2 different services create a conflict?

@exekias Your input here would be great.

@jsoriano
Copy link
Member Author

If we go with munin.metrics we would have it very similar to what we do with Prometheus.

Ok, I'll go for munin.metrics. I think that a good addition in the future could be to extract labels from the metric names, and split events by that. We could keep the metrics in munin.metrics and the extracted labels in munin.labels or in ECS fields. In any case this won't be breaking because metric names could follow the same rules.

We could remove the namespace option. Instead we would introduce configuration of service.name and service.type. for filtering per service. Or even have namespace as a config option but it does not change the metric prefix.

Do we have a name for the settings to override service.type and service.name?

I'll use namespace by now to set both values instead of adding it to the metric names.

Could it happen that 2 different services create a conflict?

Metric names should match ^[a-zA-Z_][a-zA-Z0-9_]*$, the dot has special meanings in munin, so I don't think we can have conflicts because of that. We are not checking now that the names are correct, I could add a check to avoid problems caused by wrong plugins.

There can be two plugins writing to the same fields things with different meanings, in that case there won't be mapping conflicts and the user can set namespace/service.type to differentiate.

@@ -4,8 +4,10 @@
Munin node metrics exporter
release: beta
fields:
- name: munin
type: group
- name: munin.*
Copy link
Contributor

Choose a reason for hiding this comment

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

you can remove the .* part, it seems that's how we normally do it in fields.yml, the timeseries.instance code will be easier too

Copy link
Member Author

Choose a reason for hiding this comment

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

This looks needed in this case, maybe because I am setting up dynamic templates for two levels now.

- name: munin.*
type: object
object_type: double
object_type_mapping_type: 'long'
Copy link
Contributor

Choose a reason for hiding this comment

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

why long here? I would perhaps expect:
object_type_mapping_type: "*"

Copy link
Member Author

Choose a reason for hiding this comment

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

I needed objects to keep being objects, I have added two patterns now, one for the level of groups and another one for the metrics.

@exekias
Copy link
Contributor

exekias commented Jan 25, 2019

I don't have a strong opinion on prepending metrics or not, great to see this implemented here too!

@jsoriano jsoriano changed the title Add mapping for munin Add mapping for munin and options to override service type and name Jan 25, 2019
metricbeat/module/munin/_meta/fields.yml Outdated Show resolved Hide resolved
metricbeat/module/munin/munin.go Show resolved Hide resolved
return event, nil

event := mb.Event{
Service: m.serviceType,
Copy link
Member

Choose a reason for hiding this comment

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

The service type should not be munin by the service that is monitored. So if apache is monitored with munin, service.type should be apache. Because of this we should also have it set by the user. I wonder if we should make it required for the user to have it set or make it optional?

Copy link
Member

@ruflin ruflin Jan 28, 2019

Choose a reason for hiding this comment

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

I had a discussion with @exekias and he proposed to have this as general option for all modules instead. Can you remove it from here and potentially open a separate PR with introducing these settings?

Copy link
Member Author

@jsoriano jsoriano Jan 28, 2019

Choose a reason for hiding this comment

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

The service type should not be munin by the service that is monitored. So if apache is monitored with munin, service.type should be apache. Because of this we should also have it set by the user. I wonder if we should make it required for the user to have it set or make it optional?

After reading this I think that another option for events could be to use the plugin name as a different field and not for the path, so if we have now an event like this:

{
  "service": {
    "type": "munin",
    "name": "somerole"
  },
  {
    "munin": {
      "metrics": {
         "apache": {
            "accesses": 42,
            "errors": 2
         },
         "cpu": {
            "system": 0.8
         },
      }
    }
  }

Have instead two like this:

{
  "service": {
    "type": "apache",
    "name": "somerole"
  },
  {
    "observer": {
      "type": "munin"
    },
    "munin": {
      "plugin": {
        "name": "apache"
      },
      "metrics": {
        "accesses": 42,
        "errors": 2
      }
    }
  }
{
  "service": {
    "type": "cpu",
    "name": "somerole"
  },
  {
    "observer": {
      "type": "munin"
    },
    "munin": {
      "plugin": {
        "name": "cpu",
      },
      "metrics": {
        "system": 0.8
      }
    }
  }

This would be more aligned with ECS-like metrics.

Copy link
Member Author

@jsoriano jsoriano Jan 28, 2019

Choose a reason for hiding this comment

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

I had a discussion with @exekias and he proposed to have this as general option for all modules instead. Can you remove it from here and potentially open a separate PR with introducing these settings?

I totally agree with having an option for service.name for all modules. Not so sure for service.type, I think that the type should be set in general by the module (do we want to allow arbitrary service.type for service modules?)

Copy link
Member

Choose a reason for hiding this comment

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

  • +1 on only allowing to set the service.type for the "input" modules. We should not allow to have it overwritten in other modules
  • It's very interesting that you set the observer above as munin and not metricbeat. @webmat This gets even more interesting now ;-)
  • I like the idea of the plugin field. How easily can this mapping be done? I assume we only have data from 1 plugin at the time?

Copy link
Member Author

@jsoriano jsoriano Jan 29, 2019

Choose a reason for hiding this comment

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

I will add a general option for service.name in other PR.

The setting of service.type and observer.type will also go in another PR, I think there can be some shared code for that in all "input" modules.

The plugin field would be quite easy, the items we are looping on here, should rather be called plugins 🙂. I'll give a try to this here.

Copy link
Member Author

Choose a reason for hiding this comment

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

PR to add service.name #10427

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

I'm pretty excited about this change. Especially the split up by plugin looks really good.

@@ -507,7 +507,15 @@ metricbeat.modules:
enabled: true
period: 10s
hosts: ["localhost:4949"]
node.namespace: node
Copy link
Member

Choose a reason for hiding this comment

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

Should we mention this removal in the changelog?

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this mention now that the refactor is so impactful. But I'll re-add something about that, yes 👍

@jsoriano jsoriano merged commit 22f530a into elastic:master Jan 31, 2019
@jsoriano jsoriano deleted the munin-fields branch January 31, 2019 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change discuss Issue needs further discussion. Metricbeat Metricbeat module review Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants