Skip to content

Commit 5e42037

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pivot
2 parents b628cd9 + c04080b commit 5e42037

File tree

103 files changed

+2503
-1162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2503
-1162
lines changed

Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: Prometheus & Grafana
3+
---
4+
5+
Databend captures real-time metrics of the meta and query services, which you can access through a web browser using the following URLs:
6+
7+
- Meta Metrics: `http://<admin_api_address>/v1/metrics`
8+
- Query Metrics: `http://<metric_api_address>/metrics`
9+
10+
Alternatively, you can use Prometheus to capture and store the metrics data from Databend. Then, you can visualize the captured time series data on a dashboard with Grafana.
11+
12+
[Prometheus](https://prometheus.io/) is an open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach. [Grafana](https://grafana.com/grafana) is an open-source tool used for analyzing and visualizing metrics.
13+
14+
This following tutorial guides you through deploying and integrating Databend, Prometheus, and Grafana. In this tutorial, you'll deploy a local Databend and install Prometheus and Grafana with Docker. Before you start, ensure that you have Docker installed.
15+
16+
## Tutorial: Monitor Databend with Prometheus & Grafana
17+
18+
### Step 1. Deploy Databend
19+
20+
Follow the [Deployment Guide](https://databend.rs/doc/deploy) to deploy a standalone Databend.
21+
22+
:::tip
23+
This tutorial uses the [default configuration files](https://github.com/datafuselabs/databend/tree/main/scripts/distribution/configs) in the `configs` folder of the install package. The metrics API for databend-meta is `0.0.0.0:28101/v1/metrics`, and the metrics API for databend-query is `0.0.0.0:7070/metrics`.
24+
:::
25+
26+
### Step 2. Deploy Prometheus
27+
28+
The steps below describe how to install and deploy Prometheus using Docker.
29+
30+
1. Pull the latest Docker image of Prometheus from the Docker Hub registry.
31+
32+
```bash
33+
docker pull prom/prometheus
34+
```
35+
36+
2. Edit the configuration file **prometheus.yml**.
37+
38+
Add the following script to the end of the file prometheus.yml that can be found in the `/etc/prometheus/prometheus.yml` directory. Please note that, with Docker, there are multiple ways to modify a file for a container. In this tutorial, we demonstrate how to achieve this by saving the file to a local folder and mapping it when running the Prometheus image.
39+
40+
:::tip
41+
Docker containers can connect to local services running on the host by using `host.docker.internal`. This feature is available by default only on Docker for Windows/Mac. However, it is also available on Linux starting from version **20.03**.
42+
:::
43+
44+
```yaml
45+
- job_name: "databend-query"
46+
47+
# metrics_path defaults to '/metrics'
48+
# scheme defaults to 'http'.
49+
50+
static_configs:
51+
- targets: ["host.docker.internal:7070"]
52+
53+
- job_name: "databend-meta"
54+
55+
metrics_path: "/v1/metrics"
56+
# scheme defaults to 'http'.
57+
58+
static_configs:
59+
- targets: ["host.docker.internal:28101"]
60+
```
61+
62+
3. Deploy Prometheus.
63+
64+
If you saved and edited the file `prometheus.yml` in a local folder, you need to create a mapping using the `-v` option in the command. To do so, replace `/path/to/prometheus.yml` in the command below with the path to your local `prometheus.yml`.
65+
66+
```bash
67+
docker run \
68+
-p 9090:9090 \
69+
--add-host=host.docker.internal:host-gateway \
70+
-v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
71+
prom/prometheus
72+
```
73+
74+
4. Check Metrics Status
75+
76+
Check the value on the right of each instance. `1` means the instance is healthy, and `0` means that the scrape failed.
77+
78+
![Prometheus up](../../public/img/tracing/prometheus-up.png)
79+
80+
### Step 3. Deploy Grafana
81+
82+
The steps below describe how to install and deploy Grafana using Docker.
83+
84+
1. Pull the latest Docker image of Grafana from the Docker Hub registry.
85+
86+
```bash
87+
docker pull grafana/grafana
88+
```
89+
90+
2. Deploy Grafana.
91+
92+
```bash
93+
docker run \
94+
-p 3000:3000 \
95+
--add-host=host.docker.internal:host-gateway \
96+
grafana/grafana
97+
```
98+
99+
3. Add a data source of Prometheus type.
100+
101+
Open your web browser and go to `http://0.0.0.0:3000`. Log in with the user name `admin` and password `admin` first, and then add a data source of Prometheus type on **Configuration** > **Data Sources** > **Add data source**.
102+
103+
Please note that set the URL to `http://host.docker.internal:9090` for the data source.
104+
105+
![Grafana data source](../../public/img/tracing/grafana-datasource.png)
106+
107+
4. Create dashboards.
108+
109+
Databend recommend import the files in [datafuselabs/helm-charts - dashboards](https://github.com/datafuselabs/helm-charts/tree/main/dashboards) to create your dashboards. To do so, download the files first, then go to `http://0.0.0.0:3000/dashboard/import` to import the downloaded files one by one and select the `Prometheus` data source for each dashboard.
110+
111+
![Grafana import query json](../../public/img/tracing/grafana-query-json.png)
112+
113+
![Grafana query dashboard](../../public/img/tracing/grafana-query-dashboard.png)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: LIST
3+
---
4+
5+
Aggregate function.
6+
7+
The LIST() function converts all the values of a column to an Array.
8+
9+
## Syntax
10+
11+
```sql
12+
LIST(expression)
13+
```
14+
15+
## Arguments
16+
17+
| Arguments | Description |
18+
| ----------- | -------------- |
19+
| expression | Any expression |
20+
21+
## Return Type
22+
23+
the Array type that use the type of the value as inner type.
24+
25+
## Examples
26+
27+
```sql
28+
SELECT LIST(number) FROM numbers(10);
29+
+-----------------------+
30+
| list(number) |
31+
+-----------------------+
32+
| [0,1,2,3,4,5,6,7,8,9] |
33+
+-----------------------+
34+
```

docs/doc/15-sql-functions/10-aggregate-functions/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ These functions help you extract and summarize data from databases to gain valua
3030
| [QUANTILE](aggregate-quantile.md) | Calculates the quantile for a specific column |
3131
| [RETENTION](aggregate-retention.md) | Calculates retention for a set of events |
3232
| [WINDOW_FUNNEL](aggregate-windowfunnel.md) | Analyzes user behavior in a time-ordered sequence of events |
33+
| [LIST](aggregate-list.md) | Converts all the values of a column to an Array |
3334

docs/doc/15-sql-functions/61-ai-functions/01-ai-to-sql.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ The SQL query statements generated adhere to the PostgreSQL standards, so they m
1414

1515
```sql
1616
USE <your-database>;
17-
SELECT * FROM ai_to_sql('<natural-language-instruction>', '<openai-api-key>');
17+
SELECT * FROM ai_to_sql('<natural-language-instruction>'[, '<openai-api-key>']);
1818
```
19-
To obtain your openAI API key, please visit https://platform.openai.com/account/api-keys and generate a new key.
19+
20+
:::tip Obtain and Save openAI API Key
21+
- To obtain your openAI API key, please visit https://platform.openai.com/account/api-keys and generate a new key.
22+
- Instead of manually entering your OpenAI API secret key every time you run the function, you can save time by adding it to the configuration file **databend-query.toml** through the `openai_api_key` setting. Databend will automatically use that secret key whenever you run the function without explicitly specifying a key as a parameter.
23+
24+
```toml
25+
openai_api_key = "<your-key>"
26+
```
27+
:::
2028

2129
## Examples
2230

182 KB
Loading
254 KB
Loading
173 KB
Loading
170 KB
Loading

src/query/ast/src/ast/format/ast_format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ impl<'ast> Visitor<'ast> for AstFormatVisitor {
692692
ExplainKind::Raw => "Raw",
693693
ExplainKind::Plan => "Plan",
694694
ExplainKind::Memo(_) => "Memo",
695+
ExplainKind::JOIN => "JOIN",
695696
ExplainKind::AnalyzePlan => "Analyze",
696697
});
697698
let format_ctx = AstFormatContext::with_children(name, 1);

0 commit comments

Comments
 (0)