Skip to content

baselime/cdk

Repository files navigation

Baselime CDK

Documentation Latest Release License

Baselime CDK offers the most effective approach to adding observability to a serverless CDK application.

baselime.Config.init(stack, {
  apiKey: 'xxxxxx',
});

new Alert("service-errors", {
  parameters: {
    query: {
      filters: [
        filter.inArray("LogLevel", ["ERROR", "WARN"]),
      ],
    },
    channels: [{ type: "slack", targets: ["baselime-alerts"] }]
  },
});

Installation

npm i @baselime/cdk

Usage

Get your baselime api key from the Baselime console or using the Baselime CLI with the command baselime iam.

// Initialize Config, you must do this in a construct before adding querys, alerts and dashboards.
baselime.Config.init(stack, {
  apiKey: 'xxxxxx',
});

// Create Query
const query = new baselime.Query("ColdStarts", {
  description: "optional",
  parameters: {
    datasets: [
      "lambda-logs",
    ],
    calculations: [
      max("@initDuration"),
      p90("@initDuration"),
      min("@initDuration"),
    ],
    filters: [
      eq("@type", "REPORT"),
    ],
  }
});

// Add an alert
query.addAlert({
  enabled: true,
  parameters: {
    frequency: '30mins',
    threshold: gt(500),
    window: '1 hour',
  },
  channels: [{ targets: ['baselime-alerts'], type: 'slack' }],
});

// Create Dashboard
new baselime.Dashboard('ServiceHealth', {
  parameters: {
    widgets: [{ query, type: WidgetType.TIMESERIES}],
  },
});

License

© Baselime Limited, 2023

Distributed under MIT License (The MIT License).

See LICENSE for more information.