Skip to content

Commit

Permalink
feat!: upgrade openmldb 0.8.4 (#43)
Browse files Browse the repository at this point in the history
* feat: upgrade openmldb 0.8.4

update deps

* feat!: rm deploy_response_time
  • Loading branch information
aceforeverd authored Nov 26, 2023
1 parent e229b16 commit e6f8ee9
Show file tree
Hide file tree
Showing 9 changed files with 441 additions and 613 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
OPENMLDB_VERSION=0.8.3
OPENMLDB_VERSION=0.8.4
ENV_TYPE=src
6 changes: 0 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ services:
openmldb-api:
image: ghcr.io/aceforeverd/openmldb-server:${OPENMLDB_VERSION}
command:
- --
- "--role=apiserver"
- "--endpoint=openmldb-api:9527"
- "--zk_cluster=openmldb-zk:2181"
Expand All @@ -70,7 +69,6 @@ services:
openmldb-ns1:
image: ghcr.io/aceforeverd/openmldb-server:${OPENMLDB_VERSION}
command:
- --
- "--role=nameserver"
- "--endpoint=openmldb-ns1:9527"
- "--zk_cluster=openmldb-zk:2181"
Expand All @@ -85,7 +83,6 @@ services:
openmldb-ns2:
image: ghcr.io/aceforeverd/openmldb-server:${OPENMLDB_VERSION}
command:
- --
- "--role=nameserver"
- "--endpoint=openmldb-ns2:9527"
- "--zk_cluster=openmldb-zk:2181"
Expand All @@ -99,7 +96,6 @@ services:
openmldb-tablet1:
image: ghcr.io/aceforeverd/openmldb-server:${OPENMLDB_VERSION}
command:
- --
- "--role=tablet"
- "--endpoint=openmldb-tablet1:9527"
- "--zk_cluster=openmldb-zk:2181"
Expand All @@ -111,7 +107,6 @@ services:
openmldb-tablet2:
image: ghcr.io/aceforeverd/openmldb-server:${OPENMLDB_VERSION}
command:
- --
- "--role=tablet"
- "--endpoint=openmldb-tablet2:9527"
- "--zk_cluster=openmldb-zk:2181"
Expand All @@ -123,7 +118,6 @@ services:
openmldb-tablet3:
image: ghcr.io/aceforeverd/openmldb-server:${OPENMLDB_VERSION}
command:
- --
- "--role=tablet"
- "--endpoint=openmldb-tablet3:9527"
- "--zk_cluster=openmldb-zk:2181"
Expand Down
4 changes: 0 additions & 4 deletions openmldb_exporter/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
table_replica,
table_disk,
table_memory,
deploy_response_time,
tablet_memory_application,
tablet_memory_actual,
)
Expand All @@ -20,7 +19,6 @@

from openmldb_exporter.collector.collectors import (
TableStatusCollector,
DeployQueryStatCollector,
ComponentStatusCollector,
Collector,
)
Expand All @@ -34,12 +32,10 @@
"table_replica",
"table_disk",
"table_memory",
"deploy_response_time",
"tablet_memory_application",
"tablet_memory_actual",
"ConfigStore",
"TableStatusCollector",
"DeployQueryStatCollector",
"ComponentStatusCollector",
"Collector",
]
54 changes: 1 addition & 53 deletions openmldb_exporter/collector/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from abc import ABC, abstractmethod
from sqlalchemy import (engine, Table, Column, MetaData, String, Integer)
from openmldb_exporter.collector import (connected_seconds, component_status, table_rows, table_partitions,
table_partitions_unalive, table_memory, table_disk, table_replica, deploy_response_time,
table_partitions_unalive, table_memory, table_disk, table_replica,
tablet_memory_application, tablet_memory_actual)
from urllib import request
import time
Expand Down Expand Up @@ -72,58 +72,6 @@ def collect(self):
table_disk.labels(tb_path, tid, storage_type).set(int(disk))


class DeployQueryStatCollector(Collector, SDKConnectable):
'''
deploy query statistics collector
'''
_metadata: MetaData
_deploy_response_time: Table

def __init__(self, conn: engine.Connection):
super().__init__(conn)
self._init_table_info()

def collect(self):
rs = self._conn.execute(self._deploy_response_time.select())
row = rs.fetchone()
acc_map = {}
while row is not None:
logging.debug(row)

dp_name, time_second, count, total = row
time_second = float(time_second)

# update bucket count
for i, bound in enumerate(deploy_response_time._upper_bounds):
if time_second <= bound:
# FIXME: handle Histogram reset correctly
deploy_response_time.labels(dp_name)._buckets[i].set(int(count))
break
# update sum for each deploy
if dp_name in acc_map:
acc_map[dp_name] += float(total)
else:
acc_map[dp_name] = float(total)
row = rs.fetchone()

# write sums
for key,value in acc_map.items():
deploy_response_time.labels(key)._sum.set(value)

def _init_table_info(self):
# sql parser do not recognize quoted string
self._metadata = MetaData(schema="INFORMATION_SCHEMA", bind=self._conn, quote_schema=False)
self._deploy_response_time = Table(
"DEPLOY_RESPONSE_TIME",
self._metadata,
Column("DEPLOY_NAME", String, quote=False),
Column("TIME", String, quote=False),
Column("COUNT", Integer, quote=False),
Column("TOTAL", String, quote=False),
quote=False,
)


class ComponentStatusCollector(Collector, SDKConnectable):
'''
component statistics and tablet memory collector
Expand Down
11 changes: 0 additions & 11 deletions openmldb_exporter/collector/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
ROLE = "role"
TABLE_ID = "tid"
TABLE_PATH = "table_path"
DEPLOY_PATH = "deploy_path"
STORAGE_MODE = "storage_mode"

component_lables = [ENDPOINT, ROLE]
Expand Down Expand Up @@ -106,13 +105,3 @@
unit="bytes",
)

BUCKETS = (1 / 1000000, 1 / 100000, 1 / 10000, 1 / 1000, 1 / 100, 1 / 10, 1, 10, 100, 1000, 10000, 100000, 1000000, INF)
deploy_response_time = Histogram(
"deploy_response_time",
"Deployment query response time histogram",
[DEPLOY_PATH],
subsystem="info_schema",
namespace=NAMESPACE,
unit="seconds",
buckets=BUCKETS,
)
3 changes: 1 addition & 2 deletions openmldb_exporter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import logging
from typing import (Iterable)

from openmldb_exporter.collector import (ConfigStore, Collector, TableStatusCollector, DeployQueryStatCollector,
from openmldb_exporter.collector import (ConfigStore, Collector, TableStatusCollector,
ComponentStatusCollector)
from prometheus_client.twisted import MetricsResource
from sqlalchemy import engine
Expand Down Expand Up @@ -55,7 +55,6 @@ def main():

collectors = (
TableStatusCollector(conn),
DeployQueryStatCollector(conn),
ComponentStatusCollector(conn),
)

Expand Down
Loading

0 comments on commit e6f8ee9

Please sign in to comment.