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 support for structured metadata #37

Closed
wants to merge 2 commits into from
Closed

Conversation

plandem
Copy link

@plandem plandem commented Nov 17, 2024

Update log_builder.ts
Added support for for structured metadata https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs

Now its possible to pass structured metadata as simple as adding object meta, e.g.:

logger.info({ foo: 'bar', meta: { id: "123456" }}, "hello world");

Added support for for structured metadata https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs

Now its possible to pass structured metadata as simple as adding object `meta`, e.g.:
```
logger.info({ foo: 'bar', meta: { id: "123456" }}, "hello world");
```
@Julien-R44
Copy link
Owner

Julien-R44 commented Nov 23, 2024

Hey, thanks for the PR

I think it's going to be a breaking change? Maybe some people use a meta key today without specifically wanting it to be a structured metadata?

Maybe this feature should be opt-in? For example enableStructuredMetadata in the options? or a structuredMetadataKey to specify the key that would be used for structured metadata? What do you think?

@plandem
Copy link
Author

plandem commented Nov 24, 2024

not breaking changes in general, but yeah, may impact in same cases. Probably you are right and its better to make an option of transport, e.g. like:

const transport = pino.transport<LokiOptions>({
  target: "pino-loki",
  options: {
    batching: true,
    interval: 5,
    metadataKey: 'meta',
    host: 'https://my-loki-instance:3100',
    basicAuth: {
      username: "username",
      password: "password",
    },
  },
});

and later to use that option.

Can you do it? I decided to switch for pull in model and use promtail, so not sure I will use/need it now.

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

Successfully merging this pull request may close these issues.

2 participants