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

Add a general purpose processor based on the Starlark language #7194

Closed
danielnelson opened this issue Mar 18, 2020 · 1 comment · Fixed by #7660
Closed

Add a general purpose processor based on the Starlark language #7194

danielnelson opened this issue Mar 18, 2020 · 1 comment · Fixed by #7660
Assignees
Labels
feature request Requests for new plugin and for new features to existing plugins
Milestone

Comments

@danielnelson
Copy link
Contributor

danielnelson commented Mar 18, 2020

Feature Request

The Starlark language is a dialect of python designed to be embedded into a larger application. The Go implementation that allows embedding the language using pure Go code and with few dependencies. It is used primarily in the Bazel build system and is well maintained.

Proposal:

Create a processor plugin that allows applying a starlark function to Telegraf metrics. Expose and document an interface for reading and modifying the metric name, tags, fields, time.

Desired behavior:

Example configuration, this script does not modify the metric but prints the values. Calling print in the processor will be connected to the Telegraf log:

[[processors.starlark]]
  source = """
def apply(metric):
    print(metric.name)
    for tag in metric.tags:
        key, value = tag
        print('tag: %s=%s' % (key, value))
    for field in metric.fields:
        key, value = field
        print('field: %s=%s' % (key, value))
    print('time:', metric.time)
    return metric
"""

Use case:

This would be a general purpose plugin which will be helpful with specialized processing and extending Telegraf without requiring new plugins. I'll be adding some additional use cases as they come up and are collected from the backlog:

  • Performing simple mathematical operations such as the division of two fields.
@danielnelson
Copy link
Contributor Author

Would also implement #3709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant