## 1. Project Overview & Quickstart (yihong0618/prompt_template_sample.txt)
# prompt_template_sample.txt
Open-source repository yihong0618/prompt_template_sample.txt
### Repository Details
- **Repository:** [yihong0618/prompt_template_sample.txt](https://github.com/yihong0618/prompt_template_sample.txt)
- **Primary Language:** Code
*Note: High-volume repository documentation is actively indexed and synchronized by YakaAI.*
## 2. Official Technical Reference & Guides (yihong0618/docs)
## File: README.md
# GreptimeDB Documentation
This directory contains sources of all content published at [docs.greptime.com][1]
[1]: https://docs.greptime.com
## Contributing
Thanks a lot for considering contributing to GreptimeDB. People like you would make
GreptimeDB a great product.
Please refer to [contribution guidelines](./CONTRIBUTING.md) for more information.
---
## File: docs/greptimecloud/migrate-to-greptimecloud/migrate-from-influxdb.md
---
keywords: [migration, InfluxDB, GreptimeCloud, HTTP API, Telegraf, client libraries, data visualization]
---
import DocTemplate from '../../db-cloud-shared/migrate/migrate-from-influxdb.md'
# Migrate from InfluxDB
Navigate to the [GreptimeCloud console](https://greptime.cloud) and click the `Connection Information` section under `Manage Your Data`.
You can find the GreptimeDB URL, database name, as well as the username and password associated with the token.
```shell
curl -X POST 'https:///v1/influxdb/api/v2/write?bucket=' \
-H 'authorization: token ' \
-d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000'
```
```shell
curl 'https:///v1/influxdb/write?db=&u=&p=' \
-d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000'
```
```toml
[[outputs.influxdb_v2]]
urls = ["https:///v1/influxdb"]
token = ":"
bucket = ""
## Leave empty
organization = ""
```
```toml
[[outputs.influxdb]]
urls = ["https:///v1/influxdb"]
database = ""
username = ""
password = ""
```
```js
'use strict'
/** @module write
**/
import { InfluxDB, Point } from '@influxdata/influxdb-client'
/** Environment variables **/
const url = 'https:///v1/influxdb'
const token = ':'
const org = ''
const bucket = ''
const influxDB = new InfluxDB({ url, token })
const writeApi = influxDB.getWriteApi(org, bucket)
writeApi.useDefaultTags({ region: 'west' })
const point1 = new Point('temperature')
.tag('sensor_id', 'TLM01')
.floatField('value', 24.0)
writeApi.writePoint(point1)
```
```python
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
bucket = ""
org = ""
token = ":"
url="https:///v1/influxdb"
client = influxdb_client.InfluxDBClient(
url=url,
token=token,
org=org
)
# Write script
write_api = client.write_api(write_options=SYNCHRONOUS)
p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=bucket, org=org, record=p)
```
```go
bucket := ""
org := ""
token := ":"
url := "https:///v1/influxdb"
client := influxdb2.NewClient(url, token)
writeAPI := client.WriteAPIBlocking(org, bucket)
p := influxdb2.NewPoint("stat",
map[string]string{"unit": "temperature"},
map[string]interface{}{"avg": 24.5, "max": 45},
time.Now())
writeAPI.WritePoint(context.Background(), p)
client.Close()
```
```java
private static String url = "https:///v1/influxdb";
private static String org = "";
private static String bucket = "";
private static char[] token = ":".toCharArray();
public static void main(final String[] args) {
InfluxDBClient influxDBClient = InfluxDBClientFactory.create(url, token, org, bucket);
WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();
Point point = Point.measurement("temperature")
.addTag("location", "west")
.addField("value", 55D)
.time(Instant.now().toEpochMilli(), WritePrecision.MS);
writeApi.writePoint(point);
influxDBClient.close();
}
```
```php
$client = new Client([
"url" => "https:///v1/influxdb",
"token" => ":",
"bucket" => "",
"org" => "",
"precision" => InfluxDB2\Model\WritePrecision::S
]);
$writeApi = $client->createWriteApi();
$dateTimeNow = new DateTime('NOW');
$point = Point::measurement("weather")
->addTag("location", "Denver")
->addField("temperature", rand(0, 20))
->time($dateTimeNow->getTimestamp());
$writeApi->write($point);
```
The GreptimeCloud console provides a Workbench for data visualization.
To use it, open the [Greptime console](https://greptime.cloud), select `Web Dashboard` under `Manage Your Data`,
then create a new Workbench file and add panels as your needs.
```shell
for file in data.*; do
curl -i --retry 3 \
-X POST "https://${GREPTIME_HOST}/v1/influxdb/write?db=${GREPTIME_DB}&u=${GREPTIME_USERNAME}&p=${GREPTIME_PASSWORD}" \
--data-binary @${file}
sleep 1
done
```
---
## File: docs/greptimecloud/migrate-to-greptimecloud/migrate-from-prometheus.md
---
keywords: [migration, Prometheus, GreptimeCloud, remote write, PromQL, Grafana]
---
import DocTemplate from '../../db-cloud-shared/migrate/_migrate-from-prometheus.md'
# Migrate from Prometheus
For information on configuring Prometheus to write data to GreptimeDB, please refer to the [remote write](/greptimecloud/integrations/prometheus.md#prometheus-remote-write) documentation.
For detailed information on querying data in GreptimeDB using Prometheus query language, please refer to the [HTTP API](/greptimecloud/integrations/prometheus.md#prometheus-http-api-and-promql) section in the PromQL documentation.
To add GreptimeDB as a Prometheus data source in Grafana, please refer to the [Grafana](/greptimecloud/integrations/grafana.md#prometheus-data-source) documentation.
---
## File: docs/greptimecloud/integrations/sdk-libraries/go.md
---
keywords: [Go SDK, gRPC, database connection, authentication, GreptimeCloud]
---
# Go SDK
The GreptimeDB Go ingester library utilizes gRPC for writing data to the database. For how to use the library, please refer to the [Go library documentation](https://docs.greptime.com/user-guide/ingest-data/for-iot/grpc-sdks/go).
To connect to GreptimeCloud, using information below:
- Host: ``
- Port: `5001`
- Database: ``
- Username: ``
- Password: ``
The following code shows how to create a `client`.
```go
cfg := greptime.NewConfig("").
WithDatabase("").
WithPort(5001).
WithInsecure(false).
WithAuth("", "")
cli, err := greptime.NewClient(cfg)
if err != nil {
panic("failed to init client")
}
```
---
## File: docs/greptimecloud/integrations/sdk-libraries/java.md
---
keywords: [Java SDK, gRPC, database connection, authentication]
---
# Java SDK
The GreptimeDB Java ingester library utilizes gRPC for writing data to the database. For how to use the library, please refer to the [Java library documentation](https://docs.greptime.com/user-guide/ingest-data/for-iot/grpc-sdks/java).
To connect to GreptimeCloud, using information below:
- Host: ``
- Port: `5001`
- Database: ``
- Username: ``
- Password: ``
The following code snippet shows how to connect to database:
```java
String database = "";
String[] endpoints = {":5001"};
AuthInfo authInfo = new AuthInfo("", "");
GreptimeOptions opts = GreptimeOptions.newBuilder(endpoints, database)
.authInfo(authInfo)
.tlsOptions(new TlsOptions())
.build();
GreptimeDB client = GreptimeDB.create(opts);
```
---
## File: docs/greptimecloud/integrations/alloy.md
---
keywords: [Grafana Alloy, Prometheus Remote Write, OpenTelemetry, data pipeline]
---
# Alloy
[Grafana Alloy](https://grafana.com/docs/alloy/latest/) is an observability data pipeline as well as an OpenTelemetry
collector distribution. You can integrate your GreptimeCloud instance as data
sinks of Alloy.
## Prometheus Remote Write
Configure GreptimeDB as remote write target.
```
// config.alloy
prometheus.remote_write "greptimedb" {
endpoint {
url = "https:///v1/prometheus/write?db="
basic_auth {
username = ""
password = ""
}
}
}
```
## OpenTelemetry
GreptimeDB can also be configured as OpenTelemetry collector.
```
// config.alloy
otelcol.exporter.otlphttp "greptimedb" {
client {
endpoint = "https:///v1/otlp/"
headers = {
"X-Greptime-DB-Name" = "",
}
auth = otelcol.auth.basic.credentials.handler
}
}
otelcol.auth.basic "credentials" {
username = ""
password = ""
}
```
---
## File: docs/greptimecloud/integrations/dbeaver.md
---
keywords: [DBeaver, MySQL, database connection, database tool, GreptimeCloud]
---
# DBeaver
[DBeaver](https://dbeaver.io/) is a free, open-source, and cross-platform database tool that supports all popular databases. It is a popular choice among developers and database administrators for its ease of use and extensive feature set.
You can use DBeaver to connect to GreptimeDB via MySQL database drivers.
Click the "New Database Connection" button in the DBeaver toolbar to create a new connection to GreptimeDB.
Select MySQL and click "Next" to configure the connection settings.
Install the MySQL driver if you haven't already.
Input the following connection details:
- Connect by Host
- Host: ``
- Port: `4002`
- Database: ``
- Enter the `` and ``
Click "Test Connection" to verify the connection settings and click "Finish" to save the connection.
For more information on interacting with GreptimeDB using MySQL, refer to the [MySQL protocol documentation](https://docs.greptime.com/user-guide/protocols/mysql).
---
## File: docs/greptimecloud/integrations/emqx.md
---
keywords: [EMQX, MQTT, IoT, data ingestion, GreptimeCloud]
---
# EMQX Platform
[EMQX Platform](https://www.emqx.io/) is an MQTT Gateway, designed to handle
massive amounts of IoT device connections and message traffic, making it a
popular choice for building large-scale IoT applications. It has built-in
support for GreptimeDB as a data integration. By adding GreptimeDB as a Data
Persistent sink, you can ingest EMQX messages into GreptimeDB automatically.
You will need to follow these steps for your complete IoT data link, from MQTT
to database:
- Sign up your account on [EMQX Platform](https://www.emqx.io/)
- Create a **Dedicated Instance** and wait for it's up and running
- Setup Private Link or NAT Gateway for your deployment so it has internet
access
- Go to **Data Integrations** and find **GreptimeDB**
- Configure your **GreptimeDB** connector using following information
- Server host: `:4001`
- Database: ``
- Username: ``
- Password: ``
Then you are all set. Start from using EMQX's debugging tools to generate data
and check GreptimeDB Dashboard for the data ingested.
---
## File: docs/greptimecloud/integrations/fluent-bit.md
---
keywords: [Fluent Bit, GreptimeCloud, metrics ingestion, logs ingestion, data pipeline]
---
# Fluent Bit
Fluent Bit is a lightweight and fast log processor and forwarder that can collect, parse, filter, and forward logs and metrics. Fluent Bit is part of the Fluentd project ecosystem and is written in C language. It is designed to be memory-efficient and performant, making it suitable for use in resource-constrained environments.
## HTTP
Fluent Bit can be configured to send logs to GreptimeCloud using the HTTP protocol. This allows you to collect logs from various sources and send them to GreptimeCloud for storage, analysis, and visualization.
```
[OUTPUT]
Name http
Match *
Host
Port 443
Uri /v1/events/logs?db=&table=&pipeline_name=
Format json
Json_date_key scrape_timestamp
Json_date_format iso8601
Tls On
compress gzip
http_User
http_Passwd
```
In this example, the `http` output plugin is used to send logs to GreptimeCloud. For more information, and extra options, refer to the [Logs HTTP API](https://docs.greptime.com/user-guide/logs/write-logs#http-api) guide.
## Prometheus Remote Write
Fluent Bit can be configured to send metrics to GreptimeCloud using the Prometheus Remote Write protocol. This allows you to collect metrics from various sources and send them to GreptimeCloud for storage, analysis, and visualization.
```
[OUTPUT]
Name prometheus_remote_write
Match internal_metrics
Host
Port 443
Uri /v1/prometheus/write?db=
Tls On
http_user
http_passwd
```
In this example, the `prometheus_remote_write` output plugin is used to send metrics to GreptimeCloud. For more information, and extra options, refer to the [Prometheus Remote Write](https://docs.greptime.com/user-guide/integrations/prometheus) guide.
## OpenTelemetry
Fluent Bit can be configured to send logs and metrics to GreptimeCloud using the OpenTelemetry protocol. This allows you to collect logs and metrics from various sources and send them to GreptimeCloud for storage, analysis, and visualization.
```
# Only for metrics
[OUTPUT]
Name opentelemetry
Alias opentelemetry_metrics
Match *_metrics
Host
Port 443
Metrics_uri /v1/otlp/v1/metrics
http_User
http_Passwd
Log_response_payload True
Tls On
compress gzip
# Only for logs
[OUTPUT]
Name opentelemetry
Alias opentelemetry_logs
Match *_logs
Host
Port 443
Logs_uri /v1/otlp/v1/logs
http_User
http_Passwd
Log_response_payload True
Tls On
compress gzip
Header X-Greptime-Log-Table-Name ""
Header X-Greptime-Log-Pipeline-Name ""
Header X-Greptime-DB-Name ""
```
In this example, the [OpenTelemetry OTLP/HTTP API](https://docs.greptime.com/user-guide/ingest-data/for-observability/opentelemetry) interface is used. For more information, and extra options, refer to the [OpenTelemetry](https://docs.greptime.com/user-guide/ingest-data/for-observability/opentelemetry) guide.
---
## File: docs/greptimecloud/integrations/grafana.md
---
keywords: [Grafana, data source, Prometheus, MySQL, GreptimeCloud]
---
# Grafana
GreptimeDB can be configured as a [Grafana data source](https://grafana.com/docs/grafana/latest/datasources/add-a-data-source/).
You have the option to connect GreptimeDB with Grafana using one of three data sources: GreptimeDB, Prometheus, or MySQL.
## GreptimeDB data source plugin
Before using the GreptimeDB data source, it is necessary to manually install the GreptimeDB data source plugin.
For more information,
please refer to the [GreptimeDB data source plugin](https://docs.greptime.com/user-guide/integrations/grafana##greptimedb-data-source-plugin) document.
Click the Add data source button and select GreptimeDB as the type. Fill in the following URL in the GreptimeDB server URL:
```txt
https://
```
Then do the following configuration:
- Database Name:``, leave it blank to use the default database `public`
- In the Auth section, click basic auth, and fill in the username and password for GreptimeDB in the Basic Auth Details section (not set by default, no need to fill in).
- User: ``
- Password: ``
Then click the Save & Test button to test the connection.
## Prometheus data source
Click the Add data source button and select Prometheus as the type.
Fill in Prometheus server URL in HTTP:
```txt
https:///v1/prometheus
```
Click basic auth in the Auth section and fill in your GreptimeDB username and password in Basic Auth Details:
- User: ``
- Password: ``
Click Custom HTTP Headers and add one header:
- Header: `x-greptime-db-name`
- Value: ``
Then click Save & Test button to test the connection.
## MySQL data source
Click the Add data source button and select MySQL as the type. Fill in the following information in MySQL Connection:
- Host: `:4002`
- Database: ``
- User: ``
- Password: ``
- Session timezone: `UTC`
Then click Save & Test button to test the connection.
Note that you need to use raw SQL editor for panel creation. SQL Builder is not
supported due to timestamp data type difference between GreptimeDB and vanilla
MySQL.