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

[dev.icinga.com #7334] GraphiteWriter: Add support for customized metric prefix names #2031

Closed
icinga-migration opened this issue Oct 1, 2014 · 10 comments
Labels
area/graphite Metrics to Graphite enhancement New feature or request
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/7334

Created by chrisjx on 2014-10-01 17:57:55 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2014-10-12 11:33:22 +00:00)
Target Version: 2.2.0
Last Update: 2014-10-17 09:05:31 +00:00 (in Redmine)


Currently the graphite writer routine builds metric names based on the following pattern:

icinga.domain_name.check_name.metric_name

Examples:

icinga.localhost.disk._boot
icinga.localhost.load.load1

In our configuration we will have multiple environments each with similar domain names. It would be very helpful for us to be able to insert the environment name between "icinga" and the "domain name".

For example, we will have a database server in 2 environments that look like this:

db01.env1.xyz  - environment 1
db01.env2.xyz  - environment 2

so the resulting output in graphite might look like this:

icinga.env1.db01_env1_xyz.load.load1
icinga.env2.db01_env2_xyz.load.load1

In the graphite tree we would see:
icinga

 + env1
 + env2
   + db01_env2_xyz
   + db02_env2_xyz

Because of the nature of domain names being reverse of most sorting methods, it would be difficult to segregate environments within the graphite tree.

Currently I assume there is a method in C** code that concatenates the elements and takes the domain name dots, converts to underscores, etc.

Perhaps there could be a config item that provides for a secondary replacement of first and second elements:

base_element="icinga"
env_element="xyz" or 
env_element=host.vars.hostenv

I have no idea how this gets implemented, so on that last point, it is just brainstorming.

Thank you for your consideration,
Chris.

Attachments

Changesets

2014-10-11 18:38:24 +00:00 by mfriedrich 57d9453

GraphiteWriter: Add support for customized metric prefix names

Allows to use runtime macros and global constants for setting
a custom metric prefix:

    const GraphiteEnv = "icinga.env1"

    object GraphiteWriter "graphite" {
      host_name_template = GraphiteEnv + ".$host.name$"
      service_name_template = GraphiteEnv + ".$host.name$.$service.name$"
    }

fixes #7334

2014-10-12 11:30:39 +00:00 by gbeutner 989125c

Make sure that names for Graphite metrics are properly escaped

refs #7334
@icinga-migration
Copy link
Author

Updated by chrisjx on 2014-10-01 18:04:24 +00:00

Correction: In the above example of what the tree might look like in Graphite (don"t see how to edit the above):

+ Graphite
   + carbon
   + icinga
     + env1
     + env2
       + db01_env2_xyz
       + db02_env2_xyz
       + ...
+ User Graphs

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-10-02 12:39:55 +00:00

Oh hi :)

I guess one thing we could do is implement macro-based templates for names:

service_name_template = "icinga.env1.$host.name$.$service.name$"
host_name_template = "icinga.env1.$host.name$"

That way you could also easily use host/service custom variables ($host.vars.env$).

@icinga-migration
Copy link
Author

Updated by chrisjx on 2014-10-02 22:46:56 +00:00

That sounds excellent... Is this the same approach used to create custom messages for notifications?

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-10-11 18:41:07 +00:00

  • File added icinga2_graphite_host_service_name_templates.png

I really like the idea. Especially since you are not bound to runtime macros but can also use global constants setting the graphite environment (which saves you the hassle of defining a host custom var everywhere or in templates).

I"ve implemented the feature already, running tests and updated documentation.

icinga2_graphite_host_service_name_templates.png

IIRC that was one of the most requested features during Icinga Camp in SFO, so I guess we"re good to go with it in 2.2.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-10-11 18:42:08 +00:00

  • Subject changed from _configurable GraphiteWriter metric name _ to GraphiteWriter: Add support for customized metric prefix names
  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
  • Target Version set to 2.2.0

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-10-11 18:45:03 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 57d9453.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-10-12 11:21:43 +00:00

  • File added graphite.png
  • Status changed from Resolved to Assigned

We still need to escape host and service names (and other macros). Have a look at the escapeFn argument for the MacroProcessor::ResolveMacros function.

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-10-12 11:33:22 +00:00

  • Status changed from Assigned to Resolved

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-10-12 14:21:06 +00:00

Missed that yesterday, thanks for the fix!

@icinga-migration
Copy link
Author

Updated by gbeutner on 2014-10-17 08:55:58 +00:00

  • Estimated Hours set to 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphite Metrics to Graphite enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant