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

Revise Templates To allow Different Types Of Filters #91

Open
zachdesai opened this issue Feb 13, 2019 · 10 comments
Open

Revise Templates To allow Different Types Of Filters #91

zachdesai opened this issue Feb 13, 2019 · 10 comments
Labels
bug Something isn't working

Comments

@zachdesai
Copy link

Is your feature request related to a problem? Please describe.
When using inputs.logparser, I'd like to template applying grok filters - this requires a file which looks like
`
[[inputs.logparser]]

files = ["/var/log/apache/access.log"]

from_beginning = False

[inputs.logparser.grok]

patterns = ["%{COMBINED_LOG_FORMAT}"]

measurement = "apache_access_log"

`
I'm unsure if this is possible already with this role, but I couldn't figure it out.

Describe the solution you'd like
Modify the templates to allow custom 'subplugins' (I don't really know the Telegraf nomenclature) - with this, you could also remove the entries for tags, tagpass, tagdrop parts and pass them as subplugins

This seems to be working for me

`{% if item.value.subplugin is defined and item.value.subplugin is iterable %}

{% for subpluginname in item.value.subplugin %}

[inputs.{{ item.value.plugin | default(item.key) }}.{{ subpluginname }}]

{% for items in item.value.subplugin[subpluginname] %}

{{ items }}

{% endfor %}

{% endfor %}

{% endif %}
`

Additional context

eg group_vars file
logparser:
config:
- files = ["/var/log/apache/access.log"]
- from_beginning = False
subplugin:
grok:
- patterns = ["%{COMBINED_LOG_FORMAT}"]
- measurement = "apache_access_log"

@dj-wasabi dj-wasabi added bug Something isn't working help wanted labels Mar 10, 2019
@mcaulifn
Copy link

mcaulifn commented May 2, 2019

Found this while searching: https://github.com/jtyr/yaml2toml-converter
Might be helpful for a completely generic template

@dj-wasabi
Copy link
Owner

@mcaulifn That looks nice, ever worked with it?

@mcaulifn
Copy link

mcaulifn commented May 3, 2019

just found it and then tried it out. there seem to be a few kinks but overall a great start.

telegraf_custom_plugins_extra:
  switches:
    inputs.snmp:
      agents:
        - 172.16.1.0
        - 172.16.1.6
        - 172.16.0.30
      version: 2
      community: publiv
      name: system
      field:
        - name: hostname
          oid: .1.3.6.1.2.1.1.5.0
          is_tag: true
        - name: uptime
          oid: .1.3.6.1.2.1.1.3.0
        - name: sysObjectID
          oid: .1.3.6.1.2.1.1.2.0
      table:
        - name: interface_stats
          inherit_tags:
            - hostname
          field:
            - name: ifName
              oid: .1.3.6.1.2.1.31.1.1.1.1
              is_tag: true
      tags:
          deviceType: switch
          customer: me

gets me:

[inputs.snmp]
agents = ['172.16.1.0', '172.16.1.6', '172.16.0.30']
community = "publiv"
name = "system"
version = 2

  [[inputs.snmp.field]]
  is_tag = True
  name = "hostname"
  oid = ".1.3.6.1.2.1.1.5.0"

  [[inputs.snmp.field]]
  name = "uptime"
  oid = ".1.3.6.1.2.1.1.3.0"

  [[inputs.snmp.field]]
  name = "sysObjectID"
  oid = ".1.3.6.1.2.1.1.2.0"

  [[inputs.snmp.table]]
  inherit_tags = ['hostname']
  name = "interface_stats"

    [[field]]
    is_tag = True
    name = "ifName"
    oid = ".1.3.6.1.2.1.31.1.1.1.1"

  [inputs.snmp.tags]
  customer = "me"
  deviceType = "switch"

I can hack around field being incorrect by adding inputs.snmp.table to that level. However, True should be true.

I opened an issue: jtyr/yaml2toml-converter#1

@dj-wasabi
Copy link
Owner

@mcaulifn Nice!

Do you think you can make a PR that includes the usage of the converter?

@mcaulifn
Copy link

mcaulifn commented May 4, 2019

I'd like to hear back from the author first to see if he is OK with it.

@dj-wasabi
Copy link
Owner

@mcaulifn Yeah sure, I agree. 👍

@NotDead
Copy link
Contributor

NotDead commented Sep 17, 2020

Is it still open? I have searched for snmp config and as I can see this issue is hanging.
The first time I used this role, I thought it was done like @zachdesai suggested and did the wrong config =)

@ghost
Copy link

ghost commented Aug 20, 2021

@mcaulifn Could you share to us the modifications that you did in order to get the ability to set the template like you described in #91 (comment)?

@mcaulifn
Copy link

@emiliencartesoft There is a link to another PR with the modification I made. I couldn't find anything else locally that I would have changed.

@ghost
Copy link

ghost commented Aug 20, 2021

@mcaulifn

@emiliencartesoft There is a link to another PR with the modification I made. I couldn't find anything else locally that I would have changed.

I'm sorry but where is the link of the PR? I can't find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants