Giter Club home page Giter Club logo

Comments (18)

yankcrime avatar yankcrime commented on June 24, 2024 2

@7yl4r You're right, it was shortsighted and we're jumping through hoops in the meantime as a result.

My plan is to draw a line under this module for 1.x, and to introduce 2.0 which will depend on Puppet 4 and address problems such as this.

from puppet-telegraf.

mxjessie avatar mxjessie commented on June 24, 2024 1

@yankcrime Any plans to (maybe) cut a branch for 2.0? I'm currently running into this issue with input and output plugins and I would love to try and help with this.

from puppet-telegraf.

yankcrime avatar yankcrime commented on June 24, 2024 1

Closing this now that #80 has been merged which should address these use cases / issues.

from puppet-telegraf.

nrdmn avatar nrdmn commented on June 24, 2024 1

This should work too (I didn't test this, but that's how #80 was supposed to be used)

telegraf::inputs:
  cpu:
    - percpu: true
      totalcpu: true
  exec:
    - commands:
        - who | wc -l
    - commands:
        - cat /proc/uptime | awk '{print $1}'

from puppet-telegraf.

yankcrime avatar yankcrime commented on June 24, 2024

Is this the feature you were alluding to as well @millingworth ?

from puppet-telegraf.

doomnuggets avatar doomnuggets commented on June 24, 2024

Would this slight modification work?

define telegraf::input (
  $plugin_type = $name,
  $options     = undef,
  $sections    = undef,
) {
  include telegraf

  if $options {
    validate_hash($options)
  }

  if $sections {
    validate_hash($sections)
  }

  Class['::telegraf::config']
  ->
  file {"${telegraf::config_folder}/${name}.conf $title":
    path    => "${telegraf::config_folder}/${name}.conf"
    content => template('telegraf/input.conf.erb')
  }
  ~>
  Class['::telegraf::service']
}

Note the file resource name change.

from puppet-telegraf.

cfbarbero avatar cfbarbero commented on June 24, 2024

I'm not a puppet/hiera expert, but I'm not sure that will solve my issue.

This is an example of the telegraf.conf that I'm hoping to generate:

[[inputs.httpjson]]
   name = "endpoint1"
   servers = [
      "http://localhost/foo"
   ]
   method = "GET"

[[inputs.httpjson]]
   name = "endpoint2"
   servers = [
      "http://localhost/bar"
   ]
   method = "GET"

Here's the hiera that I would think might work:

telegraf::inputs:
  httpjson:
    name: "endpoint1"
    servers:
      - "http://localhost/foo"
    method: "GET"
  httpjson:
    name: "endpoint2"
    servers:
      - "http://localhost/bar"
    method: "GET"

Would this scenario be supported?

from puppet-telegraf.

doomnuggets avatar doomnuggets commented on June 24, 2024

I doubt it. Because a hash is not able to store the same key more than once.
I tried your example code and ended up with only the last definition of httpjson (endpoint2).

I'm working on a new commit which would solve this problem by introducing a separate variable for repeated inputs.

from puppet-telegraf.

7yl4r avatar 7yl4r commented on June 24, 2024

This applies to outputs as well. For instance, consider:

            'file' => {
                'files' => [
                    "/tmp/telegraf_output_influx.out",
                ],
                'data_format' => "influx",
            },
            'file' => {
                'files' => [
                    "/tmp/telegraf_output_graphite.out",
                ],
                'data_format' => "graphite",
            },

from puppet-telegraf.

gevial avatar gevial commented on June 24, 2024

Same issue for me. Is it possible to configure multiple outputs of the same type using telegraf::output defined type?

from puppet-telegraf.

7yl4r avatar 7yl4r commented on June 24, 2024

I think this is going to require a re-structuring of the parameters into something like:

telegraf::inputs:
  - endpoint1:
        input_type: "httpjson"
        servers:
          - "http://localhost/foo"
        method: "GET"
  - endpoint2:
        input_type: "httpjson"
        servers:
          - "http://localhost/bar"
        method: "GET"

The limitation of one key having one value is part of hiera, so using input/output types (which can be repeated in the telegraf.conf) as hiera keys was a mistake. This would be a compatibility breaking feature unless the code can be modified to check telegraf::inputs for sub-keys vs an array.

from puppet-telegraf.

druchoo avatar druchoo commented on June 24, 2024

FWIW, this is my current solution which I've picked up from other modules:

Hiera:

profiles::telegraf::inputs:
  cloudwatch_qa_alb:
    plugin_type: 'cloudwatch'
    options:
      profile: 'qa'
      region: 'us-east-1'
      period: '1m'
      delay: '1m'
      interval: '1m'
      namespace: 'AWS/ApplicationELB'
      ratelimit: 20
  cloudwatch_qa_elb:
    plugin_type: 'cloudwatch'
    options:
      profile: 'qa'
      region: 'us-east-1'
      period: '1m'
      delay: '1m'
      interval: '1m'
      namespace: 'AWS/ELB'
      ratelimit: 20
  cloudwatch_dev_alb:
    plugin_type: 'cloudwatch'
    options:
      profile: 'dev'
      region: 'us-east-1'
      period: '1m'
      delay: '1m'
      interval: '1m'
      namespace: 'AWS/ApplicationELB'
      ratelimit: 20
  cloudwatch_dev_elb:
    plugin_type: 'cloudwatch'
    options:
      profile: 'dev'
      region: 'us-east-1'
      period: '1m'
      delay: '1m'
      interval: '1m'
      namespace: 'AWS/ELB'
      ratelimit: 20

Manifest:

class profiles::telegraf (
  Hash $inputs = {},
) {
  include ::telegraf

  create_resources(telegraf::input, $inputs)
}

Which generates these configs:

$ ls -1 /etc/telegraf/telegraf.d/
cloudwatch_dev_alb.conf
cloudwatch_dev_elb.conf
cloudwatch_qa_alb.conf
cloudwatch_qa_elb.conf

==> /etc/telegraf/telegraf.d/cloudwatch_dev_alb.conf <==

[[inputs.cloudwatch]]
  delay = "1m"
  interval = "1m"
  namespace = "AWS/ApplicationELB"
  period = "1m"
  profile = "dev"
  ratelimit = 20
  region = "us-east-1"

==> /etc/telegraf/telegraf.d/cloudwatch_dev_elb.conf <==

[[inputs.cloudwatch]]
  delay = "1m"
  interval = "1m"
  namespace = "AWS/ELB"
  period = "1m"
  profile = "dev"
  ratelimit = 20
  region = "us-east-1"

==> /etc/telegraf/telegraf.d/cloudwatch_qa_alb.conf <==

[[inputs.cloudwatch]]
  delay = "1m"
  interval = "1m"
  namespace = "AWS/ApplicationELB"
  period = "1m"
  profile = "qa"
  ratelimit = 20
  region = "us-east-1"

==> /etc/telegraf/telegraf.d/cloudwatch_qa_elb.conf <==

[[inputs.cloudwatch]]
  delay = "1m"
  interval = "1m"
  namespace = "AWS/ELB"
  period = "1m"
  profile = "qa"
  ratelimit = 20
  region = "us-east-1"

from puppet-telegraf.

nrdmn avatar nrdmn commented on June 24, 2024

I've modified this module to use a real toml generator rather than templates to fix this issue. Tests are still failing because I don't know any ruby, but everything else works fine.
See https://github.com/nrdmn/puppet-telegraf/tree/toml

This requires the toml-rb gem and slightly changes the configuration structure to match the generated toml output.

from puppet-telegraf.

AndreGirbal avatar AndreGirbal commented on June 24, 2024

We use the plugin snmp and need many "snmp.field" entries. It's impossible to do this with a hash.
It's why I change code on the template to use "sections" as an array and I could do what I want. But with this I lost ability to merge multiples files.

I use this code for "sections" in input.conf.erb:

<% @sections.each do |item| -%>
<% item.sort.each do |section, option| -%>
[[inputs.<%= section %>]]
<%      unless option == nil -%>
<%          option.sort.each do | suboption, value | -%>
  <%= suboption -%> = <% if value.is_a?(String) %>"<%= value %>"<% elsif value.is_a?(Array) %><%= value.inspect %><% else %><%= value %><% end %>
<%          end -%>
<%      end -%>
<%   end -%>
<% end -%>

Don't forget to comment "validate_hash($sections)" in input.pp

My hiera file:

telegraf::input:
  vm-labo-puppet.domain:
    plugin_type: snmp
    options:
      agents: ["vm-labo-puppet.integ.gnc:161"]
      version: 2
      name : 'vm-labo-puppet.domain*SNMP*Field'
      community: public
    sections:
    - snmp.field:
        name: 'LoadAverage_1m'
        oid: '.1.3.6.1.4.1.2021.10.1.5.1'
    - snmp.field:
        name: 'LoadAverage_5m'
        oid: '.1.3.6.1.4.1.2021.10.1.5.2'
    - snmp.field:
        name: 'LoadAverage_15m'
        oid: '.1.3.6.1.4.1.2021.10.1.5.3'
    - snmp.field:
        name: 'Memory_total'
        oid: '.1.3.6.1.4.1.2021.4.5.0'
    - snmp.field:
        name: 'Memory_Usage_availReal'
        oid: '.1.3.6.1.4.1.2021.4.6.0'
    - snmp.field:
        name: 'Memory_Usage_buffered'
        oid: '.1.3.6.1.4.1.2021.4.14.0

The conf file:

[[inputs.snmp]]
  agents = ["vm-labo-puppet.domain:161"]
  community = "public"
  name = "vm-labo-puppet.domain*SNMP*Field"
  version = 2
[[inputs.snmp.field]]
  name = "LoadAverage_1m"
  oid = ".1.3.6.1.4.1.2021.10.1.5.1"
[[inputs.snmp.field]]
  name = "LoadAverage_5m"
  oid = ".1.3.6.1.4.1.2021.10.1.5.2"
[[inputs.snmp.field]]
  name = "LoadAverage_15m"
  oid = ".1.3.6.1.4.1.2021.10.1.5.3"
[[inputs.snmp.field]]
  name = "Memory_total"
  oid = ".1.3.6.1.4.1.2021.4.5.0"
[[inputs.snmp.field]]
  name = "Memory_Usage_availReal"
  oid = ".1.3.6.1.4.1.2021.4.6.0"
[[inputs.snmp.field]]
  name = "Memory_Usage_buffered"
  oid = ".1.3.6.1.4.1.2021.4.14.0"

from puppet-telegraf.

sparr avatar sparr commented on June 24, 2024

@yankcrime it is not obvious to me how to utilize the new functionality in #80 to accomplish the goal here. Can you give an example?

from puppet-telegraf.

sparr avatar sparr commented on June 24, 2024

Answering my own question:

telegraf::inputs:
  cpu:
    - percpu: true
      totalcpu: true
  exec:
    - commands:
        - who | wc -l
  exec-uptime:
    - commands:
        - cat /proc/uptime | awk '{print $1}'
      plugin_type: exec

Two exec inputs. The first one doesn't need a plugin_type because it has the "right" name. The second one the plugin_type overrides the name

from puppet-telegraf.

sparr avatar sparr commented on June 24, 2024

Does this change mean that every hiera config needs to be changed, or do old style just-one-hash-no-array configs still work?

from puppet-telegraf.

nrdmn avatar nrdmn commented on June 24, 2024

Every hiera config needs to be changed.

from puppet-telegraf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.