How can I use a custom variable in the notes_url of a service template? IcingaWeb2 does not appear to display it even correctly coded

Hi, Icinga community,

I’m working on trying to make some more useful default documentation for our services in Icinga2. We have a mediawiki instance where I am, and every individual instance of a monitor should be documented.

I use the following string in individual Service and Service Apply definitions, which works perfectly.
notes_url = “https://f.q.d.n.example.com/index.php?title=Monitor:_$service.name$

However, I’d like to make sure this is applied to all versions - the only place we want to ever document our monitors is in the wiki with a specific format so that we reliably (and always) go to the monitor page of any monitor we need to define.

However, when I set a notes_url variable in the generic-service template, nothing gets a notes_url except those I have hardcoded in the service apply rules directly - though the result does change in the object depending on how I define it:

notes_url = “https://f.q.d.n.example.com/index.php?title=Monitor:_$service.name$

results in the object having"

notes_url = “https://f.q.d.n.example.com/index.php?title=Monitor:_” + service.name

results in the object having:

However, no matter which way I setup the notes template, the services all have no Notes URL in the Icinga Web 2 application.

However, if I hardcode the notes URL in a Service apply rule directly:

notes_url = “https://f.q.d.n.example.com/index.php?title=Monitor:_$service.name$

Then the notes URL shows up correctly.

System information:

Loaded modules

|doc|2.8.2|
|monitoring|2.8.2|

Icinga Web 2 Version: 2.8.2
Browser: Firefox 107.1
PHP Version: 7.2.24
OS Version: CentOS 8

1 Like

have a look at Library Reference - Icinga 2

The answer is in the Macro’s function?

Sorry I think I was wrong and the answer isn’t there.

Maybe use the notes_url for notifications and solve the Icingaweb2 link to the wiki with shared navigation until a better solution comes up?

update to icingaweb2 2.11

I think you can achieve this with the navigation feature. It allows you to add urls in host or service view. These urls can make use host and service vars. but it is definitely not available in 2.8.2

??

This is a very old feature. Introduced with 2.0 or 2.1.

thats right, I saw this feature in the youtube videos of osmc, checked out an old icingaweb2 version (2.10) and thought it was missing because I clicked on the “shared navigation” menu and mixed things up, sorry for that.

I’ve upgraded to 2.13, and the template still doesn’t work, unfortunately, in the generic-service template.

its not a template, and has nothing to do with icinga2 (2.13) but with icingaweb2

https://your-icinga-master/icingaweb2/navigation

there you can specify action urls, these urls are rendered within the monitoring module view of a host or service. It can contain host vars. this is a similar approach to a note_url approach since its added to the monitoring object, and clickable

1 Like

so did that help solving your problem?

Hi,

@moreamazingnick - I have only just returned from the year-end holiday due to a personal issue. I left just in-time to miss your reply on the 22nd, I do apologize.

So, if I understand correctly, you’re recommending that instead of using the Notes URL, that I use the Action URL fields in order to render this as expected?

no, it’s a navigation item, look at the screenshots and my post with the icingaweb2 url

these navigation items can use vars.
for a type you choose host action or service action depending on the right url for the object.

The url will be rendered in your monitoring object under problem handling → actions

I’ve never used the New Navigation entry before. I think I’ll be able to get it to work now that I’ve figured out where the navigation items are! Thank you!