Token substitution - Looping over arrays/lists

Hey guys,

Is there any way to loop over an array when using token substitution? I’ve tried the obvious, but no dice.

For example, if I had a client that had children: [ ‘child-a’, ‘child-b’], I’d like to be able to use :::children.hosts::: in a check named ‘check-children’. This way, each client can be responsible for its children (This is just an example, it could be NICs, services, etc.) and I can contain all of the templating for the checks in the client.json and manage with config management.

I realise this is very close to becoming over-complicated, but this doesn’t seem like too much of a stretch? Alternatively, can the new proxy check features help me achieve this? I know there has been some progress towards generating checks based on client attributes.

If there’s another way to achieve this - or if I’m approaching this all wrong - I’m all ears!

Regards,

James.

I could parse the raw array in the check (Depending if it gets mangled at all) and just fire the results back at the API, but then that requires extra parsing, formatting, etc. and the API URI to be hard-coded or stored as another host variable!

···

On Tuesday, April 18, 2017 at 3:17:30 PM UTC+1, James Booth wrote:

Hey guys,

Is there any way to loop over an array when using token substitution? I’ve tried the obvious, but no dice.

For example, if I had a client that had children: [ ‘child-a’, ‘child-b’], I’d like to be able to use :::children.hosts::: in a check named ‘check-children’. This way, each client can be responsible for its children (This is just an example, it could be NICs, services, etc.) and I can contain all of the templating for the checks in the client.json and manage with config management.

I realise this is very close to becoming over-complicated, but this doesn’t seem like too much of a stretch? Alternatively, can the new proxy check features help me achieve this? I know there has been some progress towards generating checks based on client attributes.

If there’s another way to achieve this - or if I’m approaching this all wrong - I’m all ears!

Regards,

James.