From 087e0015342fd6cb18b8c4a4a01b771dcb1c0401 Mon Sep 17 00:00:00 2001 From: rozetko Date: Tue, 16 Aug 2022 16:36:01 +0300 Subject: [PATCH] rename files --- spec/elasticsearch.jest.ts | 4 ++-- spec/postgres.jest.ts | 4 ++-- spec/prometheus.jest.ts | 4 ++-- spec/utils.jest.ts | 2 +- .../connector_factory.ts} | 14 +++++++------- .../elasticsearch.ts} | 2 +- .../graphite_metric.ts => connectors/graphite.ts} | 2 +- src/{metrics/metric.ts => connectors/index.ts} | 0 .../influxdb_metric.ts => connectors/influxdb.ts} | 2 +- .../mysql_metric.ts => connectors/mysql.ts} | 2 +- .../postgres_metric.ts => connectors/postgres.ts} | 2 +- .../prometheus.ts} | 2 +- src/{metrics/sql_metric.ts => connectors/sql.ts} | 4 ++-- src/{metrics => connectors}/utils.ts | 0 src/index.ts | 4 ++-- src/models/query_config.ts | 4 ++-- src/services/direct_service.ts | 2 +- src/services/grafana_service.ts | 2 +- src/tsdb-kit/index.ts | 4 ++-- src/types.ts | 2 +- 20 files changed, 31 insertions(+), 31 deletions(-) rename src/{metrics/metrics_factory.ts => connectors/connector_factory.ts} (68%) rename src/{metrics/elasticsearch_metric.ts => connectors/elasticsearch.ts} (99%) rename src/{metrics/graphite_metric.ts => connectors/graphite.ts} (98%) rename src/{metrics/metric.ts => connectors/index.ts} (100%) rename src/{metrics/influxdb_metric.ts => connectors/influxdb.ts} (98%) rename src/{metrics/mysql_metric.ts => connectors/mysql.ts} (53%) rename src/{metrics/postgres_metric.ts => connectors/postgres.ts} (55%) rename src/{metrics/prometheus_metric.ts => connectors/prometheus.ts} (98%) rename src/{metrics/sql_metric.ts => connectors/sql.ts} (95%) rename src/{metrics => connectors}/utils.ts (100%) diff --git a/spec/elasticsearch.jest.ts b/spec/elasticsearch.jest.ts index 438427d..cebb818 100644 --- a/spec/elasticsearch.jest.ts +++ b/spec/elasticsearch.jest.ts @@ -1,5 +1,5 @@ -import { ElasticsearchMetric } from '../src/metrics/elasticsearch_metric'; -import { Datasource, DatasourceType } from '../src/metrics/metric'; +import { ElasticsearchMetric } from '../src/connectors/elasticsearch'; +import { Datasource, DatasourceType } from '../src/connectors'; import 'jest'; import * as _ from 'lodash'; diff --git a/spec/postgres.jest.ts b/spec/postgres.jest.ts index 755cf0c..4fb9433 100644 --- a/spec/postgres.jest.ts +++ b/spec/postgres.jest.ts @@ -1,5 +1,5 @@ -import { PostgresMetric } from '../src/metrics/postgres_metric'; -import { DatasourceType, DatasourceQuery } from '../src/metrics/metric'; +import { PostgresMetric } from '../src/connectors/postgres'; +import { DatasourceType, DatasourceQuery } from '../src/connectors'; import 'jest'; import * as _ from 'lodash'; diff --git a/spec/prometheus.jest.ts b/spec/prometheus.jest.ts index a681a88..0a86b1e 100644 --- a/spec/prometheus.jest.ts +++ b/spec/prometheus.jest.ts @@ -1,6 +1,6 @@ import 'jest'; -import { PrometheusMetric } from '../src/metrics/prometheus_metric'; -import { DatasourceType } from '../src/metrics/metric'; +import { PrometheusMetric } from '../src/connectors/prometheus'; +import { DatasourceType } from '../src/connectors'; describe('Test Prometheus time range processing', function() { diff --git a/spec/utils.jest.ts b/spec/utils.jest.ts index 3162e85..75e4f15 100644 --- a/spec/utils.jest.ts +++ b/spec/utils.jest.ts @@ -1,4 +1,4 @@ -import { processSQLLimitOffset } from '../src/metrics/utils'; +import { processSQLLimitOffset } from '../src/connectors/utils'; import 'jest'; diff --git a/src/metrics/metrics_factory.ts b/src/connectors/connector_factory.ts similarity index 68% rename from src/metrics/metrics_factory.ts rename to src/connectors/connector_factory.ts index 67be2c1..c99d384 100644 --- a/src/metrics/metrics_factory.ts +++ b/src/connectors/connector_factory.ts @@ -1,10 +1,10 @@ -import { InfluxdbMetric } from './influxdb_metric'; -import { GraphiteMetric } from './graphite_metric'; -import { DatasourceConnector, DatasourceType } from './metric'; -import { PrometheusMetric } from './prometheus_metric'; -import { PostgresMetric } from './postgres_metric'; -import { ElasticsearchMetric } from './elasticsearch_metric'; -import { MysqlMetric } from './mysql_metric'; +import { InfluxdbMetric } from './influxdb'; +import { GraphiteMetric } from './graphite'; +import { DatasourceConnector, DatasourceType } from '.'; +import { PrometheusMetric } from './prometheus'; +import { PostgresMetric } from './postgres'; +import { ElasticsearchMetric } from './elasticsearch'; +import { MysqlMetric } from './mysql'; import { QueryConfig } from '../models/query_config'; diff --git a/src/metrics/elasticsearch_metric.ts b/src/connectors/elasticsearch.ts similarity index 99% rename from src/metrics/elasticsearch_metric.ts rename to src/connectors/elasticsearch.ts index 58d2344..385f5a0 100644 --- a/src/metrics/elasticsearch_metric.ts +++ b/src/connectors/elasticsearch.ts @@ -1,4 +1,4 @@ -import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from './metric'; +import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from '.'; import { TsdbKitError } from '../types'; import * as _ from 'lodash'; diff --git a/src/metrics/graphite_metric.ts b/src/connectors/graphite.ts similarity index 98% rename from src/metrics/graphite_metric.ts rename to src/connectors/graphite.ts index fa32290..c29ab79 100644 --- a/src/metrics/graphite_metric.ts +++ b/src/connectors/graphite.ts @@ -1,4 +1,4 @@ -import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from './metric'; +import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from '.'; import * as _ from 'lodash'; diff --git a/src/metrics/metric.ts b/src/connectors/index.ts similarity index 100% rename from src/metrics/metric.ts rename to src/connectors/index.ts diff --git a/src/metrics/influxdb_metric.ts b/src/connectors/influxdb.ts similarity index 98% rename from src/metrics/influxdb_metric.ts rename to src/connectors/influxdb.ts index 1e0ecca..d391c97 100644 --- a/src/metrics/influxdb_metric.ts +++ b/src/connectors/influxdb.ts @@ -1,4 +1,4 @@ -import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from './metric'; +import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from '.'; import { processSQLLimitOffset } from './utils'; diff --git a/src/metrics/mysql_metric.ts b/src/connectors/mysql.ts similarity index 53% rename from src/metrics/mysql_metric.ts rename to src/connectors/mysql.ts index c831a9f..5e7394f 100644 --- a/src/metrics/mysql_metric.ts +++ b/src/connectors/mysql.ts @@ -1,4 +1,4 @@ -import { SqlMetric } from './sql_metric'; +import { SqlMetric } from './sql'; export class MysqlMetric extends SqlMetric { diff --git a/src/metrics/postgres_metric.ts b/src/connectors/postgres.ts similarity index 55% rename from src/metrics/postgres_metric.ts rename to src/connectors/postgres.ts index 423a130..6c1b3e1 100644 --- a/src/metrics/postgres_metric.ts +++ b/src/connectors/postgres.ts @@ -1,4 +1,4 @@ -import { SqlMetric } from './sql_metric'; +import { SqlMetric } from './sql'; export class PostgresMetric extends SqlMetric { diff --git a/src/metrics/prometheus_metric.ts b/src/connectors/prometheus.ts similarity index 98% rename from src/metrics/prometheus_metric.ts rename to src/connectors/prometheus.ts index 66c1e48..7615c17 100644 --- a/src/metrics/prometheus_metric.ts +++ b/src/connectors/prometheus.ts @@ -1,4 +1,4 @@ -import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from './metric'; +import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from '.'; const QUERY_TIME_REGEX = /\&start=[^\&]*\&end=[^\&]*\&/; diff --git a/src/metrics/sql_metric.ts b/src/connectors/sql.ts similarity index 95% rename from src/metrics/sql_metric.ts rename to src/connectors/sql.ts index aa59237..bfc9399 100644 --- a/src/metrics/sql_metric.ts +++ b/src/connectors/sql.ts @@ -1,9 +1,9 @@ -import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from './metric'; +import { DatasourceConnector, Datasource, DatasourceQuery, DataTable } from '.'; import { processSQLLimitOffset } from './utils'; import * as _ from 'lodash'; -// for 26.09.2020 it works for all SQL datasources +// as of 26.09.2020, it works for all SQL datasources export class SqlMetric extends DatasourceConnector { private _targetName: string; //save first target name, while multi metric not implemented private url: string = 'api/tsdb/query'; diff --git a/src/metrics/utils.ts b/src/connectors/utils.ts similarity index 100% rename from src/metrics/utils.ts rename to src/connectors/utils.ts diff --git a/src/index.ts b/src/index.ts index e36d7e1..b0acdc7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ -import { DataTable, QueryType } from './metrics/metric'; +import { DataTable, QueryType } from './connectors'; import { QueryConfig } from './models/query_config'; import { queryDirect } from './services/direct_service'; import { queryGrafana } from './services/grafana_service'; import { BadRange } from './types'; export { QueryConfig } from './models/query_config'; -export { Datasource, DatasourceType, DataTable } from './metrics/metric' +export { Datasource, DatasourceType, DataTable } from './connectors' export { DatasourceUnavailable } from './types'; export { GrafanaUnavailable } from './services/grafana_service'; diff --git a/src/models/query_config.ts b/src/models/query_config.ts index c9af5ec..ce42f46 100644 --- a/src/models/query_config.ts +++ b/src/models/query_config.ts @@ -1,5 +1,5 @@ -import { Datasource, DatasourceConnector } from '../metrics/metric'; -import { connectorFactory } from '../metrics/metrics_factory'; +import { Datasource, DatasourceConnector } from '../connectors'; +import { connectorFactory } from '../connectors/connector_factory'; export class QueryConfig { diff --git a/src/services/direct_service.ts b/src/services/direct_service.ts index 7668ebd..c069a30 100644 --- a/src/services/direct_service.ts +++ b/src/services/direct_service.ts @@ -1,5 +1,5 @@ import { DatasourceUnavailable } from '../types'; -import { Datasource, DatasourceQuery } from '../metrics/metric'; +import { Datasource, DatasourceQuery } from '../connectors'; import axios from 'axios'; import * as _ from 'lodash'; diff --git a/src/services/grafana_service.ts b/src/services/grafana_service.ts index 4ee4c8a..d852a31 100644 --- a/src/services/grafana_service.ts +++ b/src/services/grafana_service.ts @@ -1,4 +1,4 @@ -import { Datasource, DatasourceQuery } from '../metrics/metric'; +import { Datasource, DatasourceQuery } from '../connectors'; import { TsdbKitError, DatasourceUnavailable } from '../types'; import axios from 'axios'; diff --git a/src/tsdb-kit/index.ts b/src/tsdb-kit/index.ts index 136ca3b..8179455 100644 --- a/src/tsdb-kit/index.ts +++ b/src/tsdb-kit/index.ts @@ -1,12 +1,12 @@ import { queryByConfig, QueryConfig } from '..'; -import { DatasourceType, QueryType } from '../metrics/metric'; +import { DatasourceType, QueryType } from '../connectors'; import * as _ from 'lodash'; // TODO: these `const`s should be CLI arguments -const PROMETHEUS_URL = 'http://prometheus.metrics.corpglory.com'; +const PROMETHEUS_URL = 'http://localhost:9090'; const QUERY = '100-(avg by (instance) (irate(node_cpu_seconds_total{job="nvicta-ai-node-exporter",mode="idle"}[5m])) * 100)'; const FROM = 1660307430000; // ms const TO = 1660307437000; // ms diff --git a/src/types.ts b/src/types.ts index d5c30b2..209b386 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { DatasourceType } from './metrics/metric'; +import { DatasourceType } from './connectors'; export class TsdbKitError extends Error {