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

filename with name Variable instead of host variable in graphite #199

Open
stonby opened this issue Aug 12, 2024 · 0 comments
Open

filename with name Variable instead of host variable in graphite #199

stonby opened this issue Aug 12, 2024 · 0 comments

Comments

@stonby
Copy link

stonby commented Aug 12, 2024

Does anyone know how to get the Name of a Device instead of the IP passed as Filename to graphite?
I would like to use the name Filed instead of the Host Field, as the Tree would be better readable.

Config:

probes:
  - name: blub
    type: std_fping
    output:
      - graphite_loss

    groups:
      - name: Group1
        hosts:
          - host: 10.11.12.13
            name: Device1

plugins:
  - name: graphite_loss
    type: graphite

    filename: "{source}-{host}-{field}"
    graphite_host: "127.0.0.1"
    protocol: "http"
    prefix: vaping
    field: loss

When Changing the Line of filename to name

    filename: "{source}-{name}-{field}"

Vaping crashes with this Stacktrace:

vaping.daemon stopping graphite_loss daemon.py:256
vaping.daemon stopping blub daemon.py:256
Traceback (most recent call last):
  File "/opt/vaping/./bin/vaping", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/vaping/cli.py", line 77, in start
    daemon.run()
  File "/opt/vaping/lib/python3.12/site-packages/vaping/daemon.py", line 246, in run
    return self._main()
           ^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/vaping/daemon.py", line 212, in _main
    vaping.io.join_plugins(self.joins)
  File "/opt/vaping/lib/python3.12/site-packages/vaping/io.py", line 32, in join_plugins
    asyncio_run(run_plugins())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/vaping/io.py", line 30, in run_plugins
    await asyncio.gather(*tasks)
  File "/opt/vaping/lib/python3.12/site-packages/vaping/plugins/__init__.py", line 280, in _run
    await self.emit_all()
  File "/opt/vaping/lib/python3.12/site-packages/vaping/plugins/__init__.py", line 251, in emit_all
    await self.send_emission()
  File "/opt/vaping/lib/python3.12/site-packages/vaping/plugins/__init__.py", line 244, in send_emission
    await emit()
  File "/opt/vaping/lib/python3.12/site-packages/vaping/plugins/__init__.py", line 228, in emit
    emitter.emit(msg)
  File "/opt/vaping/lib/python3.12/site-packages/vaping/plugins/__init__.py", line 585, in emit
    filename = self.format_filename(message, row)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/vaping/lib/python3.12/site-packages/vaping/plugins/__init__.py", line 563, in format_filename
    return self.filename.format(**self.filename_formatters(data, row))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'name'
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