Skip to content

Allow dots in identifiers #53

@nachtjasmin

Description

@nachtjasmin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions