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

Using Liquid in the options keys of agents #3367

Open
gms8994 opened this issue Mar 22, 2024 · 0 comments
Open

Using Liquid in the options keys of agents #3367

gms8994 opened this issue Mar 22, 2024 · 0 comments

Comments

@gms8994
Copy link

gms8994 commented Mar 22, 2024

First off, thank you for Huginn. I've tried using it for several years and never had a good use case for it, but it's been on my radar for a long time. The fact that it's still here is a testament to the product and to the team!

I have an EventFormattingAgent that's taking input from a WebsiteAgent. I'd like the resulting output of the EventFormattingAgent to have keys that are based on an item in the input - in short, I'm trying to use EventFormattingAgent to format the events such that they could be put in to prometheus. However, Huginn doesn't seem to apply liquid templating to the keys of the options, only to the values. When I dry run the agent, I get the unmodified version of the keys as shown below.

Am I doing something wrong? Is there a better way to get what I want?

EventFormattingAgent options
{
  "instructions": {
    "action{{ prom_gauge_group_start }}{{gauge}}{{ prom_gauge_group_end }}": "{{ action }}",
    "bankfull{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "{{ bankfull }}",
    "flood{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "{{ flood }}",
    "moderate{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "{{ moderate }}",
    "major{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "{{ major }}",
    "record{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "{{ record }}",
    "forecast{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "{{ forecast }}"
  },
  "mode": "clean"
}
Incoming data
{
  "action": "...",
  "bankfull": "...",
  "flood": "...",
  "moderate": "...",
  "major": "...",
  "record": "...",
  "forecast": "...",
  "gauge": "...",
  "prom_gauge_group_start": "...",
  "prom_gauge_group_end": "..."
}
Dry run results
[
  {
    "action{{ prom_gauge_group_start }}{{gauge}}{{ prom_gauge_group_end }}": "21",
    "bankfull{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "20",
    "flood{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "23",
    "moderate{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "30",
    "major{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "38",
    "record{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "5215",
    "forecast{% raw %}{{gauge=\"{% endraw %}{{gauge}}{% raw %}}}{%endraw%}": "1250"
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant