Telemetry.Exploration
A saved exploration: one chart with its queries and variables over logs,
metrics or traces, kept in Explore (and in an ExplorationGroup
through explorationGroupId). Chart.exploration(...) turns any
Chart helper’s chart into its chart and queries. An
Alert can watch it through explorationId.
name defaults to a generated unique name. A funnel’s sourceId and
sourceType are create-only and never returned: changing one replaces
the exploration. chart and queries are compared member by member
with the live exploration, so what the API fills in (the chart’s name,
setting defaults) is not a change; variables are matched by name,
ignoring the built-in variables it adds. An update replaces each of them
whole. Removing explorationGroupId clears it.
Saving an exploration
Section titled “Saving an exploration”Error rate as a line chart
const Chart = BetterStack.Telemetry.Chart;yield* BetterStack.Telemetry.Exploration("error-rate", { name: "Error rate", dateRangeFrom: "now-24h", dateRangeTo: "now", ...Chart.exploration( Chart.line({ sql: Chart.timeSeries({ where: `${Chart.json("level")} = 'error'` }) }), ),});As the API takes it
yield* BetterStack.Telemetry.Exploration("errors-raw", { name: "Errors", chart: { chartType: "line_chart" }, queries: [ { queryType: "sql_expression", sqlQuery: "SELECT {{time}} AS time, count(*) AS value FROM {{source}} WHERE dt BETWEEN {{start_time}} AND {{end_time}} GROUP BY time", }, ],});chart CreateExplorationRequestChart required
Chart settings. chart_type is required on create. A funnel's settings accept funnel_unit_name, the word the chart counts in. The chart is always placed at x: 0, y: 0, w: 12, h: 10, and its name comes from the exploration's name. Returned without an id.
queries CreateExplorationRequestQueriesItem[] required
The chart's queries, oldest first. Updating an exploration replaces all of its queries. Each query accepts only the keys its query_type uses. A sql_expression query uses sql_query and source_variable. A tail_query uses where_condition and source_variable. A static_text query uses static_text, and a funnel_query uses funnel_query. A key another type uses, or more than one query on a chart other than line_chart, is refused.
dateRangeFrom string
Start of the default date range, such as now-3h. A funnel's range starts at now-7d by default. Once set, it can't be cleared.
dateRangeTo string
End of the default date range, such as now. Once set, it can't be cleared.
explorationGroupId string | null
Group this exploration belongs to. Send null or "0" to remove it from its group.
name string
Exploration name (the chart is named after it). Defaults to a unique name generated from the stack, stage and logical id.
product "telemetry" | "rum" | string
The Explore the exploration lives in. Leave it out on create to put the exploration in Telemetry's Explore. A funnel over web events goes in RUM's Explore instead. Changing it moves the exploration to the other Explore.
sourceId string
ID of the source a funnel reads. Required when creating a funnel, and accepted only then. Other explorations pick their sources in the source variable.
sourceType "web_events" | "logs" | "spans" | string
The events a funnel reads from its source. When source_type is left out or the source doesn't have those events, the funnel reads the first of web events, logs and spans that the source has.
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.
variables CreateExplorationRequestVariablesItem[]
Template variables, which the queries use by name. See Query variables. An update replaces all variables, so a variable you leave out is removed, except the built-in time, start_time, end_time and source variables, which always exist. For a variable that already exists, any of default_values, sql_definition and structured_value you leave out keeps its value, unless variable_type changes, which clears them. allow_multiple_values you leave out keeps its value too. A variable sent without values gets empty values, except a source variable, which keeps its sources when you leave out both values and structured_value. sql_definition applies only to select_with_sql and multi_select_with_sql variables. allow_multiple_values is saved only for select_value and select_with_sql variables. When a variable is saved with 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. An ISO 8601 date in a date or datetime variable is saved in values as a Unix timestamp in microseconds. A new or changed sql_definition or filter sql runs against the selected source, and the change is refused when the query fails. A source variable's values are the IDs of your sources. In a rum exploration, pick each source as its web events, <table_name>:web_events. A funnel can't have variables, and its source is set in source_id.
Attributes
Section titled “Attributes”id string always set
The exploration's id.
chart ExplorationChart
Chart settings. chart_type is required on create. A funnel's settings accept funnel_unit_name, the word the chart counts in. The chart is always placed at x: 0, y: 0, w: 12, h: 10, and its name comes from the exploration's name. Returned without an id.
createdAt string
When the exploration was created.
dateRangeFrom string
Start of the default date range, such as now-3h. A funnel's range starts at now-7d by default. Once set, it can't be cleared.
dateRangeTo string
End of the default date range, such as now. Once set, it can't be cleared.
explorationGroupId string | null
Group this exploration belongs to.
name string
Exploration name. Until you name the exploration, a name generated from its query is returned. The chart is named after the exploration, so you never send a chart name.
product "telemetry" | "rum"
The Explore the exploration lives in. Leave it out on create to put the exploration in Telemetry's Explore. A funnel over web events goes in RUM's Explore instead. Changing it moves the exploration to the other Explore.
queries ExplorationQueriesItem[]
The chart's queries, oldest first. Updating an exploration replaces all of its queries. Each query accepts only the keys its query_type uses. A sql_expression query uses sql_query and source_variable. A tail_query uses where_condition and source_variable. A static_text query uses static_text, and a funnel_query uses funnel_query. A key another type uses, or more than one query on a chart other than line_chart, is refused.
teamId string
Team that owns the exploration, such as t123.
teamName string
Name of the team that owns the exploration.
updatedAt string
When the exploration was last updated.
variables ExplorationVariablesItem[]
Template variables, which the queries use by name. See Query variables. An update replaces all variables, so a variable you leave out is removed, except the built-in time, start_time, end_time and source variables, which always exist. For a variable that already exists, any of default_values, sql_definition and structured_value you leave out keeps its value, unless variable_type changes, which clears them. allow_multiple_values you leave out keeps its value too. A variable sent without values gets empty values, except a source variable, which keeps its sources when you leave out both values and structured_value. sql_definition applies only to select_with_sql and multi_select_with_sql variables. allow_multiple_values is saved only for select_value and select_with_sql variables. When a variable is saved with 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. An ISO 8601 date in a date or datetime variable is saved in values as a Unix timestamp in microseconds. A new or changed sql_definition or filter sql runs against the selected source, and the change is refused when the query fails. A source variable's values are the IDs of your sources. In a rum exploration, pick each source as its web events, <table_name>:web_events. A funnel can't have variables, and its source is set in source_id.
Lookup
Section titled “Lookup”Exploration.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.