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

feat: add labels meta #959

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: add labels meta #959

wants to merge 3 commits into from

Conversation

shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Sep 19, 2024

Allows the ability to add meta via labels.* fields

fixes #729 !!

This will only work with kibana 8.16.0 with PR elastic/kibana#193250 !!


  monitor.use({
    id: 'example-monitor',
    schedule: 10,
    labels: {
      foo: 'bar',
      team: 'synthetics',
    }
  });

lightweight


heartbeat.monitors:
- type: http
  name: Todos Lightweight
  id: "todos- light  weightt
  enabled: true
  urls: "https://elastic.github.io/synthetics-demo"
  schedule: '@every 3m10s'
  timeout: 16s
  alert.status.enabled: true
  labels.environment: "production"
  labels.team: "todos"

@emilioalvap
Copy link
Contributor

@shahzad31 I'm worried this will confusing since the lightweight representation is not a valid heartbeat monitor and effectively undocumented, wdyt?

@shahzad31
Copy link
Contributor Author

shahzad31 commented Sep 19, 2024

@shahzad31 I'm worried this will confusing since the lightweight representation is not a valid heartbeat monitor and effectively undocumented, wdyt?

@emilioalvap i will create a docs issue in a follow up to document this.

@@ -268,6 +268,7 @@ export function buildMonitorFromYaml(
enabled: config.enabled ?? options.enabled,
locations: options.locations,
tags: options.tags,
labels: parseLabels(config, options.labels),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this new field to some of the unit tests validating lightweight monitors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have added here 200e52f (#959)

@@ -255,6 +255,7 @@ export type PushOptions = Partial<ProjectSettings> &
kibanaVersion?: string;
yes?: boolean;
tags?: Array<string>;
labels?: Record<string, string>;
Copy link
Member

@vigneshshanmugam vigneshshanmugam Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this to fields to map with the heartbeat top level fields name and under the hood in Kibana, you can map to labels. Having labels as top level is confusing - https://www.elastic.co/guide/en/beats/heartbeat/8.12/configuration-general-options.html#libbeat-configuration-fields

Also let's write JS doc annotation so it's visible on TS config.

@@ -472,6 +472,50 @@ heartbeat.monitors:
hosts: ['elastic.co:443'],
});
});

it('supports labels in config', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add test for browser monitor as well.

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.

[Synthetics] - add meta information to monitoring data
3 participants