question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to add LABELS with forward slash for Elastic Common Schema (ECS) formatting

See original GitHub issue

Environment:

  • Jib version: 3.2.1
  • Build tool: Maven 3.6.3
  • OS: macOS Monterey

Description of the issue: I would like to build an image with filebeat LABELS in order to push Elastic Common Schema (ECS) formatting logs to my Elastic instance. See documentation here. The problem is I am not able to set labels as there is a forward slash in the key:

co.elastic.logs/json.keys_under_root: true
co.elastic.logs/json.overwrite_keys: true
co.elastic.logs/json.add_error_key: true
co.elastic.logs/json.expand_keys: true

Is there any way to deal with that situation? Or Maybe is that possible to integrate the possibility to set labels another way as:

            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <from>
                        <image>gcr.io/distroless/java17-debian11</image>
                    </from>
                    <to>
                        <image>...</image>
                    </to>
                    <container>
                        <ports>
                            <port>8080</port>
                        </ports>
                        <labels>
                            "co.elastic.logs/json.keys_under_root"=true
                            "co.elastic.logs/json.overwrite_keys"=true
                            "co.elastic.logs/json.add_error_key"=true
                            "co.elastic.logs/json.expand_keys"=true
                        </labels>
                    </container>
                </configuration>
            </plugin>

Expected behavior:

Steps to reproduce:

jib-maven-plugin Configuration:

            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <from>
                        <image>gcr.io/distroless/java17-debian11</image>
                    </from>
                    <to>
                        <image>...</image>
                    </to>
                    <container>
                        <ports>
                            <port>8080</port>
                        </ports>
                        <labels>
                           <co.elastic.logs/json.keys_under_root>true</co.elastic.logs/json.keys_under_root>
                           <co.elastic.logs/json.overwrite_keys>true</co.elastic.logs/json.overwrite_keys>
                           <co.elastic.logs/json.add_error_key>true</co.elastic.logs/json.add_error_key>
                           <co.elastic.logs/json.expand_keys>true</co.elastic.logs/json.expand_keys>
                        </labels>
                    </container>
                </configuration>
            </plugin>

Log output:

Additional Information:

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chanseokohcommented, Aug 23, 2022

One workaround is to set Maven properties. System properties (e.g., -Djib.container.labels=... on the command-line) also work. The format is comma-separated key-value pairs:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    ...
    <jib.container.labels>co.elastic.logs/json.keys_under_root=true,co.elastic.logs/json.overwrite_keys=true</jib.container.labels>
  </properties>

Looks like we can use Properties instead of Map for our configuration Mojo, which seems backward-compatible. But I think it would still not be possible to use special characters in key names due to the XML syntax constraint.

0reactions
mpeddada1commented, Aug 25, 2022

Thank you so much for the workaround Chanseok! And thanks for verifying @HamedKaramoko! Hopefully this will be helpful for those who come across this issue in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECS fields | Filebeat Reference [8.5] - Elastic
This section defines Elastic Common Schema (ECS) fields—a common set of fields to be used when storing event data in Elasticsearch.
Read more >
AWS::Logs::LogGroup - AWS CloudFormation
Log group names consist of the following characters: a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), '/' (forward slash), and '.' (period). Syntax. To...
Read more >
Troubleshooting the GitLab agent for Kubernetes
This error occurs when the kas-address doesn't include a trailing slash. To fix this issue, make sure that the wss or ws URL...
Read more >
class ECS. Client - Boto3 Docs 1.26.27 documentation
Amazon Elastic Container Service (Amazon ECS) is a highly scalable, fast, ... The name can't include hyphens (-), tilde (~), greater than (>),...
Read more >
Logstash: Path to ECS for 8.0 - YouTube
The Elastic Common Schema is a community-driven effort to provide consistent semantic meaning to datasets so that data from disparate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found