Skip to content

Commit

Permalink
Merge pull request #2 from GreptimeCloudStarters/endpoint-option
Browse files Browse the repository at this point in the history
feat: support endpoint option
  • Loading branch information
sunng87 authored Nov 23, 2023
2 parents f64a80e + 60025a0 commit f7d1bb0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This is a quick start demo for [GreptimeCloud](https://greptime.cloud/). It coll
Use the following command line to start sending metrics without cloning the project:

```shell
npx greptime-cloud-quick-start --host=<host> --db=<dbname> --username=<username> --password=<password>
npx greptime-cloud-quick-start --endpoint=<endpoint-url> --db=<dbname> --username=<username> --password=<password>
```

Or clone the project and run the following command line:

```shell
npm install
npx ts-node app.ts --host=<host> --db=<dbname> --username=<username> --password=<password>
npx ts-node app.ts --endpoint=<endpoint-url> --db=<dbname> --username=<username> --password=<password>
```

## npm-publish
Expand Down
18 changes: 9 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ function main() {
const db = argv.db || 'public';
const username = argv.username;
const password = argv.password;
const secure = argv.secure;
const endpoint = argv.endpoint;
const port = argv.port;
var url = '';
if (secure) {
url = `https://`;
if (endpoint != '') {
url = endpoint;
}
else {
url = `http://`;
}
url += `${dbHost}`;
if (port) {
url += `:${port}`;
url = `https://`;
url += `${dbHost}`;
if (port) {
url += `:${port}`;
}
url += `/v1/otlp/v1/metrics`;
}
url += `/v1/otlp/v1/metrics`;
const auth = Buffer.from(`${username}:${password}`).toString('base64');
const metricReader = new sdk_metrics_1.PeriodicExportingMetricReader({
exporter: new exporter_metrics_otlp_proto_1.OTLPMetricExporter({
Expand Down
23 changes: 10 additions & 13 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,21 @@ function main() {
const db = argv.db || 'public'
const username = argv.username
const password = argv.password
const secure = argv.secure
const endpoint = argv.endpoint
const port = argv.port

var url = ''
if (secure) {
url = `https://`
if (endpoint != '') {
url = endpoint
} else {
url = `http://`
url = `https://`
url += `${dbHost}`
if (port) {
url += `:${port}`
}
url += `/v1/otlp/v1/metrics`
}

url += `${dbHost}`

if (port) {
url += `:${port}`
}

url += `/v1/otlp/v1/metrics`

const auth = Buffer.from(`${username}:${password}`).toString('base64')
const metricReader = new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({
Expand Down

0 comments on commit f7d1bb0

Please sign in to comment.