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

Allow dots in identifiers #53

Open
nachtjasmin opened this issue Aug 15, 2024 · 2 comments
Open

Allow dots in identifiers #53

nachtjasmin opened this issue Aug 15, 2024 · 2 comments

Comments

@nachtjasmin
Copy link

nachtjasmin commented Aug 15, 2024

Describe the bug
Grafana Alloy is a telemetry collector that uses a HCL-like language for configuration. Their configuration language "alloy" is almost exactly like HCL, except that it also seems to support dots in block identifiers.

Example, copied from their documentation:

// Collection: mount a local directory with a certain path spec
local.file_match "applogs" {
    path_targets = [{"__path__" = "/tmp/app-logs/app.log"}]
}

// Collection: Take the file match as input, and scrape those mounted log files
loki.source.file "local_files" {
    targets    = local.file_match.applogs.targets

    // This specifies which component should process the logs next, the "link in the chain"
    forward_to = [loki.process.add_new_label.receiver]
}

// Transformation: pull some data out of the log message, and turn it into a label
loki.process "add_new_label" {
    stage.logfmt {
        mapping = {
            "extracted_level" = "level",
        }
    }

    // Add the value of "extracted_level" from the extracted map as a "level" label
    stage.labels {
        values = {
            "level" = "extracted_level",
        }
    }

    // The next link in the chain is the local_loki "receiver" (receives the telemetry)
    forward_to = [loki.write.local_loki.receiver]
}

// Anything that comes into this component gets written to the loki remote API
loki.write "local_loki" {
    endpoint {
        url = "http://loki:3100/loki/api/v1/push"
    }
}

It would be nice if this could be supported by this tree-sitter syntax. I know it's not exactly HCL, but I am not sure whether it already makes sense to fork this repo just for this minor addition.

To Reproduce
Steps to reproduce the behavior:

  1. Write HCL-like syntax like above.
  2. The tree-sitter marks this as invalid syntax.

Expected behavior
I'd like to see the dots supported in identifiers.

Screenshots
None.

Additional context
None.

@MichaHoffmann
Copy link
Collaborator

I think we could support them, but we also could add a dialect for "alloy" in case that some other rules also change eventually?

@nachtjasmin
Copy link
Author

If that's possible, sure, sounds like a good idea!

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

2 participants