Telemetry.Dashboard
A dashboard of charts over logs, metrics and traces. The dashboard holds
the range, refresh interval and query variables; its charts and sections
are their own resources (DashboardChart, DashboardSection)
that reference it by dashboardId, and the typed Chart helpers
build their queries.
A dashboard can also start from a template (templateId, from the
dashboard templates list) or be set up for a source (sourceId): both are
create-only and never returned, so changing one replaces the dashboard.
name defaults to a generated unique name; removing dashboardGroupId
clears it. variables are matched by name against the live dashboard,
ignoring the built-in time, start_time, end_time and source
variables the API adds; a change sends them all (an update replaces the
list, and a variable you drop is removed).
Bringing a dashboard built in the web app under the stack: declare it
with its exact name and deploy with --adopt (it is taken over, not
recreated), or reference it read-only with Dashboard.lookup({ id }),
the number in its address.
A dashboard with charts
Section titled “A dashboard with charts”Errors over time, an error count, and a runbook
const Chart = BetterStack.Telemetry.Chart;const app = yield* BetterStack.Telemetry.Dashboard("app", { name: "Production app", dateRangeFrom: "now-6h", dateRangeTo: "now",});const errors = `${Chart.json("level")} = 'error'`;yield* BetterStack.Telemetry.DashboardChart("errors", { dashboardId: app.id, ...Chart.line({ name: "Errors", sql: Chart.timeSeries({ where: errors }) }), x: 0, y: 0, w: 8, h: 4,});yield* BetterStack.Telemetry.DashboardChart("error-count", { dashboardId: app.id, ...Chart.number({ name: "Errors", sql: Chart.total({ where: errors }), settings: { colorMode: "high_red", colorUpperThreshold: 100, colorLowerThreshold: 10 }, }), x: 8, y: 0, w: 4, h: 4,});yield* BetterStack.Telemetry.DashboardChart("runbook", { dashboardId: app.id, ...Chart.markdown("On call? Start with the [runbook](https://wiki.example.com/runbook)."), x: 0, y: 4, w: 12, h: 2,});Variables
Section titled “Variables”A select variable the charts filter by
yield* BetterStack.Telemetry.Dashboard("by-env", { name: "By environment", variables: [ { name: "env", variableType: "select_value", defaultValues: ["production", "staging"] }, ],});Looking up an existing dashboard
Section titled “Looking up an existing dashboard”Reference a dashboard built in the web app
const existing = BetterStack.Telemetry.Dashboard.lookup({ id: "1234" });Reference a dashboard by name (fails with AmbiguousLookup when several share it)
const overview = BetterStack.Telemetry.Dashboard.lookup({ name: "Service overview" });dashboardGroupId string | null
Group this dashboard belongs to. Send null or 0 to remove it from its group.
dateRangeFrom string
Default range start, for example now-3h.
dateRangeTo string
Default range end, for example now.
name string
Dashboard name. Defaults to a unique name generated from the stack, stage and logical id.
product "telemetry" | "rum" | string
The product the dashboard belongs to. Defaults to telemetry, and it can't be changed after create.
refreshInterval number
How often the dashboard refreshes its charts, in seconds. 0 turns automatic refresh off.
resourceGroupName string
Name of the dashboard group to put the new dashboard in. Your group with that name is used, or created when there's none. Send it instead of dashboard_group_id.
sourceEligibilitySql string | null
SQL that decides which sources this dashboard's charts can read. Returned when you get one dashboard.
sourceId string
ID of the source or application to set the new dashboard up for, as List sources or List applications lists it. For a rum dashboard, source_id is an application's ID. With source_id, creating a dashboard accepts name, product, template_id, either dashboard_group_id or resource_group_name, and refresh_interval, date_range_from, date_range_to and source_eligibility_sql. variables isn't accepted with source_id.
teamId string
Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.
templateId string
ID of the dashboard template to create the dashboard from, as List dashboard templates lists it. The dashboard starts with the template's charts, sections, alerts, variables and settings. With template_id, creating a dashboard accepts name, product, source_id, either dashboard_group_id or resource_group_name, and refresh_interval, date_range_from, date_range_to and source_eligibility_sql, which replace the template's. variables isn't accepted with a template.
variables CreateDashboardRequestVariablesItem[]
The dashboard's variables, which chart queries use by name, such as {{source}}. Returned when you get one dashboard. See Query variables. - Built-in variables: Every dashboard has the built-in time, start_time, end_time and source variables, which are added when you leave them out and keep their own type. - Updating: An update replaces all variables, so a variable you leave out is removed, except the built-in ones. - Fields you leave out: For a variable that already exists, any of variable_type, default_values, sql_definition, structured_value and allow_multiple_values you leave out keeps its value, and null clears any of them except variable_type. - values: A variable's values aren't kept between updates, so send them again. A source variable keeps its sources when you leave out both values and structured_value. - Empty values: A select_value variable gets the first of its default_values, and a string, number, boolean or sql_expression variable gets all of them. A select_with_sql variable whose sql_definition is new or changed gets the first option its SQL returns. - Changing variable_type: The old default_values, sql_definition and structured_value are cleared. - sql_definition: Only select_with_sql and multi_select_with_sql variables accept a sql_definition. A new or changed sql_definition or filter sql runs against the selected source, and the change is refused when the query fails. - Dates: An ISO 8601 date in a date or datetime variable is saved in values as a Unix timestamp in microseconds.
Attributes
Section titled “Attributes”id string always set
The dashboard's id.
charts DashboardChartsItem[]
A summary of each chart on the dashboard, ordered top to bottom, then left to right. Returned when you get one dashboard. Use Get dashboard chart for a chart's queries and settings.
createdAt string
When the dashboard was created.
dashboardGroupId string | null
Group this dashboard belongs to.
dateRangeFrom string
Default range start, for example now-3h.
dateRangeTo string
Default range end, for example now.
hasOverlaps boolean
Whether any charts overlap on the grid. Returned when you get one dashboard.
name string
Dashboard name.
product "telemetry" | "rum"
The product the dashboard belongs to. Defaults to telemetry, and it can't be changed after create.
refreshInterval number
How often the dashboard refreshes its charts, in seconds. 0 turns automatic refresh off.
sections DashboardSectionsItem[]
Sections on the dashboard. Returned when you get one dashboard.
sourceEligibilitySql string | null
SQL that decides which sources this dashboard's charts can read. Returned when you get one dashboard.
teamId string
Team that owns the dashboard, such as t123.
teamName string
Name of the team that owns the dashboard.
updatedAt string
When the dashboard was last updated.
url string
Link to this dashboard's page in the Better Stack web app.
variables DashboardVariablesItem[]
The dashboard's variables, which chart queries use by name, such as {{source}}. Returned when you get one dashboard. See Query variables. - Built-in variables: Every dashboard has the built-in time, start_time, end_time and source variables, which are added when you leave them out and keep their own type. - Updating: An update replaces all variables, so a variable you leave out is removed, except the built-in ones. - Fields you leave out: For a variable that already exists, any of variable_type, default_values, sql_definition, structured_value and allow_multiple_values you leave out keeps its value, and null clears any of them except variable_type. - values: A variable's values aren't kept between updates, so send them again. A source variable keeps its sources when you leave out both values and structured_value. - Empty values: A select_value variable gets the first of its default_values, and a string, number, boolean or sql_expression variable gets all of them. A select_with_sql variable whose sql_definition is new or changed gets the first option its SQL returns. - Changing variable_type: The old default_values, sql_definition and structured_value are cleared. - sql_definition: Only select_with_sql and multi_select_with_sql variables accept a sql_definition. A new or changed sql_definition or filter sql runs against the selected source, and the change is refused when the query fails. - Dates: An ISO 8601 date in a date or datetime variable is saved in values as a Unix timestamp in microseconds.
Lookup
Section titled “Lookup”Dashboard.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
teamId string
Team that owns it, such as t123. Defaults to the credentials' team.