Loading list of config parameters into custom beat

Is there a way to load a multiple parameters into array/list type structure from your custom beat.yml file? all the custom beat tutorials only show loading one parameter into a singular variable

for example...

if you have this setup in your custombeat.yml file

<custombeat>:
  # Defines how often an event is sent to the output
  period: 1s

  queues:
    - name: test1
      group: group1
    - name: test2
      group: group2
    - name: test3
      group: group3

can you load it into your config.go file as an array to aceess the values of queue like so


type Config struct {
	Period time.Duration `config:"period"`
	Queues types.Array `config:"queues"'`
}

trying to access the values from the go code but doesn't seem to work
is there another practical way to do this? thanks.

....
similarly for the lsbeat

type Config struct {
	Period time.Duration `config:"period"`
	Path   string        `config:"path"`
}
lsbeat:
  # Defines how often an event is sent to the output
  period: 10s
  path: "."

this shows adding one path to "monitor", is it possible to make it a list of paths instead that can be inserted into the config file and interpreted by the go code for the lsbeat?

Found a solution, you can simply use one of many yaml parsers provided by go to crawl through your yaml file and store the desired variables to an array or map. more information can be found here

http://sweetohm.net/article/go-yaml-parsers.en.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.