Skip to content

Commit

Permalink
Merge pull request #2439 from MicrosoftDocs/main638671177814973480syn…
Browse files Browse the repository at this point in the history
…c_temp

For protected branch, push strategy should use PR and merge to target branch method to work around git push error
  • Loading branch information
learn-build-service-prod[bot] authored Nov 13, 2024
2 parents 10d2134 + 41eab58 commit cdd5cd3
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 15 deletions.
1 change: 1 addition & 0 deletions data-explorer/kusto/functions-library/functions-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The following section contains functions for rendering interactive [Plotly chart
| Function Name | Description |
|--|--|
| [plotly_anomaly_fl()](plotly-anomaly-fl.md) | Render anomaly chart using a Plotly template. |
| [plotly_gauge_fl()](plotly-gauge-fl.md) | Render gauge chart using a Plotly template. |
| [plotly_scatter3d_fl()](plotly-scatter3d-fl.md) | Render 3D scatter chart using a Plotly template. |

## PromQL functions
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions data-explorer/kusto/functions-library/plotly-anomaly-fl.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ monikerRange: "microsoft-fabric || azure-data-explorer || azure-monitor || micro
The function `plotly_anomaly_fl()` is a [user-defined function (UDF)](../query/functions/user-defined-functions.md) that allows you to customize a [plotly](https://plotly.com/python/) template to create an interactive anomaly chart.

::: moniker range="azure-data-explorer"
The function accepts a table containing the source and the baseline time series, lists of positive and negative anomalies with their respective sizes, and chart labeling string. The function returns a single cell table containing [plotly JSON](https://plotly.com/chart-studio-help/json-chart-schema/). Optionally, you can render the data in an [Azure Data Explorer dashboard](/azure/data-explorer/azure-data-explorer-dashboards) tile. For more information, see [Plotly (preview)](../query/visualization-plotly.md).
::: moniker-end
::: moniker range="microsoft-fabric"
The function accepts a table containing the source and the baseline time series, lists of positive and negative anomalies with their respective sizes, and chart labeling string. The function returns a single cell table containing [plotly JSON](https://plotly.com/chart-studio-help/json-chart-schema/). Optionally, you can render the data in a [Real-Time dashboard](/fabric/real-time-intelligence/dashboard-real-time-create) tile. For more information, see [Plotly (preview)](../query/visualization-plotly.md).
::: moniker-end

:::moniker range="azure-data-explorer"
> [!NOTE]
Expand Down Expand Up @@ -205,7 +210,12 @@ demo_make_series2

**Output**

::: moniker range="azure-data-explorer"
The output is a Plotly JSON string that can be rendered using '| render plotly' or in an Azure Data Explorer dashboard tile. For more information on creating dashboard tiles, see [Visualize data with Azure Data Explorer dashboards ](/azure/data-explorer/azure-data-explorer-dashboards).
::: moniker-end
::: moniker range="microsoft-fabric"
The output is a Plotly JSON string that can be rendered in a Real-Time dashboard tile. For more information on creating dashboard tiles, see [Real-Time dashboards](/fabric/real-time-intelligence/dashboard-real-time-create).
::: moniker-end

The following image shows a sample anomaly chart using the above function:

Expand Down
162 changes: 162 additions & 0 deletions data-explorer/kusto/functions-library/plotly-gauge-fl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
title: plotly_gauge_fl()
description: Learn how to use the plotly_gauge_fl() user-defined function.
ms.reviewer: adieldar
ms.topic: reference
ms.date: 11/12/2024
monikerRange: "microsoft-fabric || azure-data-explorer || azure-monitor || microsoft-sentinel"
---
# plotly_gauge_fl()

>[!INCLUDE [applies](../includes/applies-to-version/applies.md)] [!INCLUDE [fabric](../includes/applies-to-version/fabric.md)] [!INCLUDE [azure-data-explorer](../includes/applies-to-version/azure-data-explorer.md)] [!INCLUDE [monitor](../includes/applies-to-version/monitor.md)] [!INCLUDE [sentinel](../includes/applies-to-version/sentinel.md)]
The function `plotly_gauge_fl()` is a [user-defined function (UDF)](../query/functions/user-defined-functions.md) that allows you to customize a [plotly](https://plotly.com/python/) template to create a [gauge chart](https://plotly.com/python/gauge-charts/).

::: moniker range="azure-data-explorer"
The function accepts few parameters to customize the gauge chart and returns a single cell table containing [plotly JSON](https://plotly.com/chart-studio-help/json-chart-schema/). Optionally, you can render the data in an [Azure Data Explorer dashboard](/azure/data-explorer/azure-data-explorer-dashboards) tile. For more information, see [Plotly (preview)](../query/visualization-plotly.md).
::: moniker-end
::: moniker range="microsoft-fabric"
The function accepts few parameters to customize the gauge chart and returns a single cell table containing [plotly JSON](https://plotly.com/chart-studio-help/json-chart-schema/). Optionally, you can render the data in a [Real-Time dashboard](/fabric/real-time-intelligence/dashboard-real-time-create) tile. For more information, see [Plotly (preview)](../query/visualization-plotly.md).
::: moniker-end

## Prerequisite

Extract the required 'gauge' template from the publicly available `PlotlyTemplate` table. Copy this table from the Samples database to your database by running the following KQL command from your target database:

```kusto
.set PlotlyTemplate <| cluster('help.kusto.windows.net').database('Samples').PlotlyTemplate
```

## Syntax

`T | invoke plotly_gauge_fl(`*value*`,` *max_range*`,` *mode*`,` *chart_title*`,` *font_color*`,` *bar_color*`,` *bar_bg_color*`,` *tick_color*`,` *tick_width*`)`

[!INCLUDE [syntax-conventions-note](../includes/syntax-conventions-note.md)]

## Parameters

| Name | Type | Required | Description |
|--|--|--|--|
| *value* | `real` | :heavy_check_mark: | The number to be displayed.|
| *max_range* | `range` | | The maximum range of the gauge.|
| *mode* | `string` | | Specifies how the value is displayed on the graph. Default is 'gauge+number'.|
| *chart_title* | `string` | | The chart title. The default is empty title.|
| *font_color* | `string` | | The chart's font color. Default is 'black'.|
| *bar_color* | `string` | | The gauge's filled bar color. Default is 'green'.|
| *bar_bg_color* | `string` | | The gauge's not filled bar color. Default is 'lightgreen'.|
| *tick_color* | `string` | | The gauge's ticks color. Default is 'darkblue'.|
| *tick_width* | `int` | | The gauge's ticks width. Default is 1.|

Plotly gauge charts support many parameters, still this function exposes only the above ones. For more information, see [indicator traces reference](https://plotly.com/python/reference/indicator/).

## Function definition

You can define the function by either embedding its code as a query-defined function, or creating it as a stored function in your database, as follows:

### [Query-defined](#tab/query-defined)

Define the function using the following [let statement](../query/let-statement.md). No permissions are required.

> [!IMPORTANT]
> A [let statement](../query/let-statement.md) can't run on its own. It must be followed by a [tabular expression statement](../query/tabular-expression-statements.md). To run a working example of `plotly_gauge_fl()`, see [Example](#example).
```kusto
let plotly_gauge_fl=(value:real, max_range:real=real(null), mode:string='gauge+number', chart_title:string='',font_color:string='black',
bar_color:string='green', bar_bg_color:string='lightgreen', tick_color:string='darkblue', tick_width:int=1)
{
let gauge_chart = toscalar(PlotlyTemplate | where name == "gauge" | project plotly);
print plotly = gauge_chart
| extend plotly=replace_string(plotly, '$VALUE$', tostring(value))
| extend plotly=replace_string(plotly, '$MAX_RANGE$', iff(isnull(max_range), 'null', tostring(max_range)))
| extend plotly=replace_string(plotly, '$MODE$', mode)
| extend plotly=replace_string(plotly, '$TITLE$', chart_title)
| extend plotly=replace_string(plotly, '$FONT_COLOR$', font_color)
| extend plotly=replace_string(plotly, '$BAR_COLOR$', bar_color)
| extend plotly=replace_string(plotly, '$BAR_BG_COLOR$', bar_bg_color)
| extend plotly=replace_string(plotly, '$TICK_COLOR$', tick_color)
| extend plotly=replace_string(plotly, '$TICK_WIDTH$', tostring(tick_width))
| project plotly
};
// Write your query to use your function here.
```

### [Stored](#tab/stored)

Define the stored function once using the following [`.create function`](../management/create-function.md). [Database User permissions](../access-control/role-based-access-control.md) are required.

> [!IMPORTANT]
> You must run this code to create the function before you can use the function as shown in the [Example](#example).
```kusto
.create-or-alter function with (folder = "Packages\\Plotly", docstring = "Render gauge chart using plotly template")
plotly_gauge_fl(value:real, max_range:real=real(null), mode:string='gauge+number', chart_title:string='',font_color:string='black',
bar_color:string='green', bar_bg_color:string='lightgreen', tick_color:string='darkblue', tick_width:int=1)
{
let gauge_chart = toscalar(PlotlyTemplate | where name == "gauge" | project plotly);
print plotly = gauge_chart
| extend plotly=replace_string(plotly, '$VALUE$', tostring(value))
| extend plotly=replace_string(plotly, '$MAX_RANGE$', iff(isnull(max_range), 'null', tostring(max_range)))
| extend plotly=replace_string(plotly, '$MODE$', mode)
| extend plotly=replace_string(plotly, '$TITLE$', chart_title)
| extend plotly=replace_string(plotly, '$FONT_COLOR$', font_color)
| extend plotly=replace_string(plotly, '$BAR_COLOR$', bar_color)
| extend plotly=replace_string(plotly, '$BAR_BG_COLOR$', bar_bg_color)
| extend plotly=replace_string(plotly, '$TICK_COLOR$', tick_color)
| extend plotly=replace_string(plotly, '$TICK_WIDTH$', tostring(tick_width))
| project plotly
}
```

---

## Example

The following example uses the [invoke operator](../query/invoke-operator.md) to run the function.

### [Query-defined](#tab/query-defined)

To use a query-defined function, invoke it after the embedded function definition.

```kusto
let plotly_gauge_fl=(value:real, max_range:real=real(null), mode:string='gauge+number', chart_title:string='',font_color:string='black',
bar_color:string='green', bar_bg_color:string='lightgreen', tick_color:string='darkblue', tick_width:int=1)
{
let gauge_chart = toscalar(PlotlyTemplate | where name == "gauge" | project plotly);
print plotly = gauge_chart
| extend plotly=replace_string(plotly, '$VALUE$', tostring(value))
| extend plotly=replace_string(plotly, '$MAX_RANGE$', iff(isnull(max_range), 'null', tostring(max_range)))
| extend plotly=replace_string(plotly, '$MODE$', mode)
| extend plotly=replace_string(plotly, '$TITLE$', chart_title)
| extend plotly=replace_string(plotly, '$FONT_COLOR$', font_color)
| extend plotly=replace_string(plotly, '$BAR_COLOR$', bar_color)
| extend plotly=replace_string(plotly, '$BAR_BG_COLOR$', bar_bg_color)
| extend plotly=replace_string(plotly, '$TICK_COLOR$', tick_color)
| extend plotly=replace_string(plotly, '$TICK_WIDTH$', tostring(tick_width))
| project plotly
};
plotly_gauge_fl(value=180, chart_title='Speed', font_color='purple', tick_width=5)
| render plotly
```

### [Stored](#tab/stored)

> [!IMPORTANT]
> For this example to run successfully, you must first run the [Function definition](#function-definition) code to store the function.
```kusto
plotly_gauge_fl(value=180, chart_title='Speed', font_color='purple', tick_width=5)
| render plotly
```

---

**Output**

::: moniker range="azure-data-explorer"
The output is a Plotly JSON string that can be rendered in an Azure Data Explorer dashboard tile. For more information on creating dashboard tiles, see [Visualize data with Azure Data Explorer dashboards](/azure/data-explorer/azure-data-explorer-dashboards).
::: moniker-end
::: moniker range="microsoft-fabric"
The output is a Plotly JSON string that can be rendered in a Real-Time dashboard tile. For more information on creating dashboard tiles, see [Real-Time dashboards](/fabric/real-time-intelligence/dashboard-real-time-create).
::: moniker-end

![Screenshot of gauge chart with random data.](media/plotly-gauge-fl\plotly-gauge-chart.png)
11 changes: 11 additions & 0 deletions data-explorer/kusto/functions-library/plotly-scatter3d-fl.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ monikerRange: "microsoft-fabric || azure-data-explorer || azure-monitor || micro
The function `plotly_scatter3d_fl()` is a [user-defined function (UDF)](../query/functions/user-defined-functions.md) that allows you to customize a [plotly](https://plotly.com/python/) template to create an interactive 3D scatter chart.

::: moniker range="azure-data-explorer"
The function accepts a table containing the records to be rendered, the names of the x, y, z & aggregation columns, and the chart title string. The function returns a single cell table containing [plotly JSON](https://plotly.com/chart-studio-help/json-chart-schema/). Optionally, you can render the data in an [Azure Data Explorer dashboard](/azure/data-explorer/azure-data-explorer-dashboards) tile. For more information, see [Plotly (preview)](../query/visualization-plotly.md).
::: moniker-end
::: moniker range="microsoft-fabric"
The function accepts a table containing the records to be rendered, the names of the x, y, z & aggregation columns, and the chart title string. The function returns a single cell table containing [plotly JSON](https://plotly.com/chart-studio-help/json-chart-schema/). Optionally, you can render the data in a [Real-Time dashboard](/fabric/real-time-intelligence/dashboard-real-time-create) tile. For more information, see [Plotly (preview)](../query/visualization-plotly.md).
::: moniker-end

## Prerequisite

Expand Down Expand Up @@ -175,7 +180,13 @@ Iris

**Output**


::: moniker range="azure-data-explorer"
The output is a Plotly JSON string that can be rendered in an Azure Data Explorer dashboard tile. For more information on creating dashboard tiles, see [Visualize data with Azure Data Explorer dashboards](/azure/data-explorer/azure-data-explorer-dashboards).
::: moniker-end
::: moniker range="microsoft-fabric"
The output is a Plotly JSON string that can be rendered in a Real-Time dashboard tile. For more information on creating dashboard tiles, see [Real-Time dashboards](/fabric/real-time-intelligence/dashboard-real-time-create).
::: moniker-end

![Screenshot of 3D scatter chart of a sample dataset.](media/plotly-scatter3d-fl\plotly-scatter3d-chart.png)

Expand Down
3 changes: 3 additions & 0 deletions data-explorer/kusto/functions-library/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ items:
- name: plotly_anomaly_fl()
displayName: functions library, Plotly, anomaly, chart, render
href: plotly-anomaly-fl.md
- name: plotly_gauge_fl()
displayName: functions library, Plotly, gauge, speed, chart, render
href: plotly-gauge-fl.md
- name: plotly_scatter3d_fl()
displayName: functions library, Plotly, scatter, chart, render
href: plotly-scatter3d-fl.md
Expand Down
17 changes: 12 additions & 5 deletions data-explorer/kusto/management/create-ingestion-mapping-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ title: .create ingestion mapping command
description: Learn how to use the `.create ingestion mapping` command to create an ingestion mapping.
ms.reviewer: orspodek
ms.topic: reference
ms.date: 08/11/2024
ms.date: 11/13/2024
---
# .create ingestion mapping command

> [!INCLUDE [applies](../includes/applies-to-version/applies.md)] [!INCLUDE [fabric](../includes/applies-to-version/fabric.md)] [!INCLUDE [azure-data-explorer](../includes/applies-to-version/azure-data-explorer.md)]
Creates an ingestion mapping that can be associated with a specific format and a specific table or database.

If a mapping with same name in the given scope already exists, `.create` will fail. Use [`.create-or-alter`](create-or-alter-ingestion-mapping-command.md) instead.
If a mapping with same name in the given scope already exists, `.create` fails. Use [`.create-or-alter`](create-or-alter-ingestion-mapping-command.md) instead.

## Permissions

Expand All @@ -38,11 +38,15 @@ At least [Database Ingestor](../access-control/role-based-access-control.md) per
> [!NOTE]
>
> * Once created, the mapping can be referenced by its name in ingestion commands, instead of specifying the complete mapping as part of the command.
> * If a mapping with the same name is created in both the table scope and the database scope, the mapping in the table scope will have a higher priority.
> * If a mapping with the same name is created in both the table scope and the database scope, the mapping in the table scope will have higher priority.
> * When ingesting into a table and referencing a mapping whose schema does not match the ingested table schema, the ingest operation will fail.
## Examples

### Create a table and database with CSV ingestion mapping

The following example creates a table, `MyTable` with CSV ingestion mapping `Mapping1` and a database, `MyDatabase` with CSV ingestion mapping `Mapping2`.

```kusto
.create table MyTable ingestion csv mapping "Mapping1"
'['
Expand All @@ -64,7 +68,9 @@ At least [Database Ingestor](../access-control/role-based-access-control.md) per
| mapping1 | CSV | `[{"Name":"rownumber","DataType":"int","CsvDataType":null,"Ordinal":0,"ConstValue":null},{"Name":"rowguid","DataType":"string","CsvDataType":null,"Ordinal":1,"ConstValue":null}]` | MyDatabase | MyTable |
| mapping2 | CSV | `[{"Name":"rownumber","DataType":"int","CsvDataType":null,"Ordinal":0,"ConstValue":null},{"Name":"rowguid","DataType":"string","CsvDataType":null,"Ordinal":1,"ConstValue":null}]` | MyDatabase | |

### Example: .create ingestion mapping with escape characters
### Create ingestion mapping with escape characters

The following example creates a table, `test_table` with JSON ingestion mapping `test_mapping_name`. To avoid errors, backslashes are used to escape single quotes in the JSON path strings.

```kusto
.create table test_table ingestion json mapping "test_mapping_name"
Expand All @@ -75,4 +81,5 @@ At least [Database Ingestor](../access-control/role-based-access-control.md) per

## Related content

* For detailed descriptions of various ingestion mapping formats such as CSV, JSON, Avro, Parquet, and Orc, see [Data mappings](mappings.md).
* For detailed descriptions of various ingestion mapping formats, such as CSV, JSON, Avro, Parquet, and Orc, see [Data mappings](mappings.md).
* To learn more about JSON mapping as an ingestion source, see [JSON mapping](json-mapping.md)
Loading

0 comments on commit cdd5cd3

Please sign in to comment.