mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 05:53:46 +08:00
Removed packahes_api relrefs. (#42017)
This commit is contained in:

committed by
GitHub

parent
68ce617f07
commit
c4b21f7b51
@ -48,7 +48,7 @@ Use the classic condition expression to create a rule that triggers a single ale
|
|||||||
|
|
||||||
To generate a separate alert for each series, create a multi-dimensional rule. Use `Math`, `Reduce`, or `Resample` expressions to create a multi-dimensional rule. For example:
|
To generate a separate alert for each series, create a multi-dimensional rule. Use `Math`, `Reduce`, or `Resample` expressions to create a multi-dimensional rule. For example:
|
||||||
|
|
||||||
- Add a `Reduce` expression for each query to aggregate values in the selected time range into a single value. (Not needed for [rules using numeric data]({{< relref "../fundamentals/grafana-managed-numeric-rule.md" >}})).
|
- Add a `Reduce` expression for each query to aggregate values in the selected time range into a single value. (Not needed for [rules using numeric data]({{< relref "../fundamentals/evaluate-grafana-alerts.md#alerting-on-numeric-data-1" >}})).
|
||||||
- Add a `Math` expression with the condition for the rule. Not needed in case a query or a reduce expression already returns 0 if rule should not fire, or a positive number if it should fire. Some examples: `$B > 70` if it should fire in case value of B query/expression is more than 70. `$B < $C * 100` in case it should fire if value of B is less than value of C multiplied by 100. If queries being compared have multiple series in their results, series from different queries are matched if they have the same labels or one is a subset of the other.
|
- Add a `Math` expression with the condition for the rule. Not needed in case a query or a reduce expression already returns 0 if rule should not fire, or a positive number if it should fire. Some examples: `$B > 70` if it should fire in case value of B query/expression is more than 70. `$B < $C * 100` in case it should fire if value of B is less than value of C multiplied by 100. If queries being compared have multiple series in their results, series from different queries are matched if they have the same labels or one is a subset of the other.
|
||||||
|
|
||||||

|

|
||||||
|
@ -76,9 +76,9 @@ Learn more about Grafana options and packages.
|
|||||||
|
|
||||||
#### Typescript
|
#### Typescript
|
||||||
|
|
||||||
- [Grafana Data]({{< relref "../../packages_api/data/_index.md" >}})
|
- Grafana Data
|
||||||
- [Grafana Runtime]({{< relref "../../packages_api/runtime/_index.md" >}})
|
- Grafana Runtime
|
||||||
- [Grafana UI]({{< relref "../../packages_api/ui/_index.md" >}})
|
- Grafana UI
|
||||||
|
|
||||||
#### Go
|
#### Go
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ The query editor for Explore is similar to the query editor for the data source
|
|||||||
.setExploreQueryField(ExploreQueryEditor);
|
.setExploreQueryField(ExploreQueryEditor);
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Add a [QueryField]({{< relref "../../packages_api/ui/queryfield.md" >}}) to `ExploreQueryEditor`.
|
1. Add a `QueryField` to `ExploreQueryEditor`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { QueryField } from '@grafana/ui';
|
import { QueryField } from '@grafana/ui';
|
||||||
|
@ -24,7 +24,7 @@ Grafana provides a couple of helper functions to interpolate variables in a stri
|
|||||||
|
|
||||||
## Interpolate variables in panel plugins
|
## Interpolate variables in panel plugins
|
||||||
|
|
||||||
For panels, the [replaceVariables]({{< relref "../../packages_api/data/panelprops.md#replacevariables-property" >}}) function is available in the [PanelProps]({{< relref "../../packages_api/data/panelprops.md" >}}).
|
For panels, the `replaceVariables` function is available in the PanelProps.
|
||||||
|
|
||||||
Add `replaceVariables` to the argument list, and pass it a user-defined template string.
|
Add `replaceVariables` to the argument list, and pass it a user-defined template string.
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ export const SimplePanel: React.FC<Props> = ({ options, data, width, height, rep
|
|||||||
|
|
||||||
## Interpolate variables in data source plugins
|
## Interpolate variables in data source plugins
|
||||||
|
|
||||||
For data sources, you need to use the [getTemplateSrv]({{< relref "../../packages_api/runtime/gettemplatesrv.md" >}}), which returns an instance of [TemplateSrv]({{< relref "../../packages_api/runtime/templatesrv.md" >}}).
|
For data sources, you need to use the getTemplateSrv, which returns an instance of TemplateSrv.
|
||||||
|
|
||||||
1. Import `getTemplateSrv` from the `runtime` package.
|
1. Import `getTemplateSrv` from the `runtime` package.
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ For more information on the available variable formats, refer to [Advanced varia
|
|||||||
|
|
||||||
## Set a variable from your plugin
|
## Set a variable from your plugin
|
||||||
|
|
||||||
Not only can you read the value of a variable, you can also update the variable from your plugin. Use [LocationSrv.update()]({{< relref "../../packages_api/runtime/locationsrv.md/#update-method" >}}) to update a variable using query parameters.
|
Not only can you read the value of a variable, you can also update the variable from your plugin. Use LocationSrv.update()
|
||||||
|
|
||||||
The following example shows how to update a variable called `service`.
|
The following example shows how to update a variable called `service`.
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ export interface MyVariableQuery {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
For a data source to support query variables, you must override the [`metricFindQuery`]({{< relref "../../packages_api/data/datasourceapi.md#metricfindquery-method" >}}) in your `DataSourceApi` class. `metricFindQuery` returns an array of [`MetricFindValue`]({{< relref "../../packages_api/data/metricfindvalue.md" >}}) which has a single property, `text`:
|
For a data source to support query variables, you must override the `metricFindQuery` in your `DataSourceApi` class. `metricFindQuery` returns an array of `MetricFindValue` which has a single property, `text`:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
async metricFindQuery(query: MyVariableQuery, options?: any) {
|
async metricFindQuery(query: MyVariableQuery, options?: any) {
|
||||||
|
@ -74,7 +74,7 @@ const frame = new MutableDataFrame({
|
|||||||
|
|
||||||
To help filter log lines, many log systems let you query logs based on metadata, or _labels_.
|
To help filter log lines, many log systems let you query logs based on metadata, or _labels_.
|
||||||
|
|
||||||
You can add labels to a stream of logs by setting the [labels](../../packages_api/data/field.md#labels-property) property on the [Field]({{< relref "../../packages_api/data/field.md" >}}).
|
You can add labels to a stream of logs by setting the labels property on the Field.
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ title = "Working with data frames"
|
|||||||
|
|
||||||
The data frame is a columnar data structure which allows efficient querying of large amounts of data. Since data frames are a central concept when developing plugins for Grafana, in this guide we'll look at some ways you can use them.
|
The data frame is a columnar data structure which allows efficient querying of large amounts of data. Since data frames are a central concept when developing plugins for Grafana, in this guide we'll look at some ways you can use them.
|
||||||
|
|
||||||
The [DataFrame]({{< relref "../../packages_api/data/dataframe.md" >}}) interface contains a `name` and an array of `fields` where each field contains the name, type, and the values for the field.
|
The DataFrame interface contains a `name` and an array of `fields` where each field contains the name, type, and the values for the field.
|
||||||
|
|
||||||
> **Note:** If you're looking to migrate an existing plugin to use the data frame format, refer to [Migrate to data frames]({{< relref "migration-guide.md#migrate-to-data-frames" >}}).
|
> **Note:** If you're looking to migrate an existing plugin to use the data frame format, refer to [Migrate to data frames]({{< relref "migration-guide.md#migrate-to-data-frames" >}}).
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ The [DataFrame]({{< relref "../../packages_api/data/dataframe.md" >}}) interface
|
|||||||
|
|
||||||
If you build a data source plugin, then you'll most likely want to convert a response from an external API to a data frame. Let's look at how to create a data frame.
|
If you build a data source plugin, then you'll most likely want to convert a response from an external API to a data frame. Let's look at how to create a data frame.
|
||||||
|
|
||||||
Let's start with creating a simple data frame that represents a time series. The easiest way to create a data frame is to use the [toDataFrame]({{< relref "../../packages_api/data/todataframe.md" >}}) function.
|
Let's start with creating a simple data frame that represents a time series. The easiest way to create a data frame is to use the toDataFrame function.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// Need to be of the same length.
|
// Need to be of the same length.
|
||||||
@ -78,7 +78,7 @@ for (let i = 0; i < frame.length; i++) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, you can use the [DataFrameView]({{< relref "../../packages_api/data/dataframeview.md" >}}), which gives you an array of objects that contain a property for each field in the frame.
|
Alternatively, you can use the DataFrameView, which gives you an array of objects that contain a property for each field in the frame.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const view = new DataFrameView(frame);
|
const view = new DataFrameView(frame);
|
||||||
@ -113,7 +113,7 @@ return (
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
To apply field options to the name of a field, use [getFieldDisplayName]({{< relref "../../packages_api/data/getfielddisplayname.md" >}}).
|
To apply field options to the name of a field, use getFieldDisplayName.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const valueField = frame.fields.find((field) => field.type === FieldType.number);
|
const valueField = frame.fields.find((field) => field.type === FieldType.number);
|
||||||
|
Reference in New Issue
Block a user