Giter VIP home page Giter VIP logo

metis's Introduction

Click me switch to English version

license Release Version PRs Welcome

Metis 这个名字取自希腊神话中的智慧女神墨提斯(Metis),它是一系列AIOps领域的应用实践集合。主要解决在质量、效率、成本方面的智能运维问题。当前版本开源的时间序列异常检测学件,是从机器学习的角度来解决时序数据的异常检测问题。

时间序列异常检测学件的实现思路是基于统计判决、无监督和有监督学习对时序数据进行联合检测。通过统计判决、无监督算法进行首层判决,输出疑似异常,其次进行有监督模型判决,得到最终检测结果。检测模型是经大量样本训练生成,可根据样本持续训练更新。

时间序列异常检测学件在织云企业版本中已覆盖 20w+ 服务器,承载了 240w+ 业务指标的异常检测。经过了海量监控数据打磨,该学件在异常检测和运维监控领域具有广泛的应用性。

另外:Metis开源项目侧重于学件的实现,利用新的方法改进一些基于规则的运维问题。学件聚焦在局部运维的解决,底层海量数据的存储和流式数据处理框架不在开源范围内,此方面的需求可在交流社区内寻找方案支持。

支持平台

目前运行的操作系统平台如下:

  • 操作系统:Linux

支持语言

目前前后端支持的开发语言如下:

  • 前端:JavaScript、TypeScript
  • 后端:Python 2.7

概览

安装指南

  • 初次安装时,请参考安装说明文档 install.md

使用指南

License

Metis的开源协议为BSD 3-Clause License,详情参见 LICENSE.TXT

贡献代码

如果您使用过程中发现问题,请通过 https://github.com/Tencent/Metis/issues 来提交并描述相关的问题,您也可以在这里查看其它的 issue ,通过解决这些 issue 来贡献代码。

如果您是第一次贡献代码,请阅读 CONTRIBUTING 了解我们的贡献流程,并提交 pull request 给我们。

腾讯开源激励计划 鼓励开发者的参与和贡献,期待你的加入。

联系方式

qq技术交流群1群:288723616。

qq_group

metis's People

Contributors

binjjam avatar codingcrush avatar ct-git avatar lxd1190 avatar wanghuaway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metis's Issues

Metis离线部署的方案

1:问一下Metis离线部署的方案
因为我所在的传统企业,生产系统都不能连外网,
所以,使用不了在线安装方式;
2:我所在的传统企业都在用CentOS 6.5,是否也支持呀?

启动服务端报错

执行命令时报错
python /data/Metis/app/controller/manage.py runserver {ip}:{port}

receive SIGCHLD
child process %s exit with exitcode %s 4721 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
receive SIGCHLD
child process %s exit with exitcode %s 4722 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
receive SIGCHLD
child process %s exit with exitcode %s 4724 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
receive SIGCHLD
child process %s exit with exitcode %s 4732 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
Performing system checksUnhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f7075217488>
Traceback (most recent call last):
  File "/root/django/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/root/django/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/root/django/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/root/django/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/root/django/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/root/django/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/root/django/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/root/django/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/django/django/urls/resolvers.py", line 559, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/root/django/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/django/django/urls/resolvers.py", line 552, in urlconf_module
    return import_module(self.urlconf_name)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/root/Metis/app/controller/settings/urls.py", line 18, in <module>
    from api import views as api_views
  File "/root/Metis/app/controller/api/views.py", line 20
    except Exception, ex:
                    ^
SyntaxError: invalid syntax

由于需要安装最新的django,必须使用python3.6,所以目前使用的是python 3.6。
是否是执行该启动服务脚本时必须用python2.7?

libdetect.so GLIBC 版本问题

libdetect.so 在加载时报错

/lib64/libc.so.6: version `GLIBC_2.14' not found

看上去这个 shared object 文件是在 glibc >= 2.14 环境下编译的,对于老平台都不兼容了。

请问能否提供一下 libdetect.so 的源码,或者提供一下使用低版本 glibc 编译得到的 so?

请问是否提供 2 维及以上多维的异常检测?

_20190224121202

如上图,看上去效果很好,但仅有一维时序异常检测。请问是否会提供 2 维及以上多维的异常检测?
因为有些异常工况,可能会考虑到多维时序在某一个时刻的综合特征,从而判断是否出故障。

关于评价指标的问题

大佬又来打扰了,有个关于precision, recall的问题想请教下。
目前metis的特征都是比较通用的,我们根据自己的业务去设计特征时是可以较好的提升模型效果,这个时候就遇到了问题,就是怎么评价模型的好坏。

单纯使用precision, recall去评价时,只要阈值设置的合适,总能够得到一个比较好的结果,但从score分布来看,情况却比较复杂。

比如:
加入某个特征,异常样本的score是有下降,但部分漏报的score增加了。又或者部分异常样本的score提升了,但正常样本的score也有了部分提升,score产生了很多的毛刺

目前我们开始着手去选择各种评价方式,改进auc,precision_recall_curve等等,因为看到你们没有在这个方面有纠结,所以想了解下你们的想法,是我们考虑太复杂了,还是有些情况没有考虑充分。

数据采集频率

数据采集1秒钟100次左右,样本如何打标和取舍?案例都是一分钟一个点

python manage.py runserver {ip}:{port} 启动报错

Performing system checks...

Unhandled exception in thread started by <function wrapper at 0x7f69aa77e410>
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/usr/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "/usr/lib/python2.7/site-packages/django/urls/resolvers.py", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "/usr/lib/python2.7/site-packages/django/urls/resolvers.py", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib64/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/data/expense-api/Metis/app/controller/settings/urls.py", line 18, in
from api import views as api_views
File "/data/expense-api/Metis/app/controller/api/views.py", line 8, in
from app.service.time_series_detector.anomaly_service import *
ImportError: No module named app.service.time_series_detector.anomaly_service

模型训练源码分析

问下在xgboost的训练中,每一个index["data"]都应该包括许多的数据点,什么样的index["data"]会认为是异常的,从而给出index["flag"]为异常呢? 是index["data"]代表的这段数据的最后一个数据点是异常,还是整个index["data"]包换的所有数据点都是异常呢

PolynomialInterpolation代码执行错误

在做多项式训练时,x_train和y_train维数明显不对,这块是否代码合入有误

我是单独调用的个函数,估计是X这块没有预处理为903长度;串起来应该没这个问题

docker安装报错

Step 1 : FROM zhiyunmetis/metis-full
 ---> 1622911b6c2e
Step 2 : WORKDIR /metis
 ---> Using cache
 ---> b48ed2668c4c
Step 3 : ADD . /metis
 ---> Using cache
 ---> 6015ba1b8dfa
Step 4 : EXPOSE 80
 ---> Using cache
 ---> dc693d43038a
Step 5 : EXPOSE 8080
 ---> Using cache
 ---> e1c6442aff3d
Step 6 : RUN chmod +x /metis/init.sh
 ---> Using cache
 ---> a757a442b401
Step 7 : CMD /bin/sh /metis/init.sh
 ---> Using cache
 ---> 508e0c2c741b
Successfully built 508e0c2c741b
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint romantic_blackwell (41ec0f0ec4e29ceddc7ea463743ac87a349c8ccaee52d2c2fbae54eff099da2a): iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8080 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1).
[root@compute1 docker]# docker run -i -t -p80:80 -p8080:8080 local/metis-demo:1.0
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint pedantic_varahamihira (296d662bd2ef5a6d06613e93f356cc2f199129512cebdcbc09a35e2c244fc289): iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8080 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
 (exit status 1).
[root@compute1 docker]# 

web表格纵坐标能否纵向放大

现在ui上只能横向放大,请问能纵向放大么?
看了一下uw-chart的相关代码是混淆过的,能否提供未混淆的版本?

关于样本构建的问题

样本构建应该是里面的核心环节,但项目里面没看到什么地方提及,所以想问下

  1. metis里面有个曲线分类,然而不同的曲线可能只是存在比较小的差异性,比如两条曲线都比较光滑,类型差不多,但某一条曲线可能会出现比较小的凸点(属于正常值),这在前面整个类别的样本库里面其实是没有的,这个时候你们一般怎么解决呢? 重新加入新曲线的正常样本?
  2. 另一个问题关于异常样本的标记,因为实际发生异常时是一个段落,如果全部标记实际会降低效果的(比如异常的起始,或者中间的某些位置,其实是相对比较正常的),这个时候你们是怎么解决的呢?
  3. 正常样本的使用,你们是进行了筛选?还是直接用某些曲线的正常值存入样本库?

缺少初始化sql文件

安装文档里的下列文件不存在

mysql -umetis -pmetis@123 -h127.0.0.1 metis < /data/Metis/app/sql/time_series_detector/anomaly.sql
mysql -umetis -pmetis@123 -h127.0.0.1 metis < /data/Metis/app/sql/time_series_detector/sample_dataset.sql
mysql -umetis -pmetis@123 -h127.0.0.1 metis < /data/Metis/app/sql/time_series_detector/train_task.sql

启动服务端错误

启动服务端程序,python /data/Metis/app/controller/manage.py runserver {ip}:{port},
选择本机 127.0.0.1,端口 12350,
运行后,浏览器 http://127.0.0.1:12350,报 "Page not found (404)“,
但是 lsof | grep 12350,可以看到处于监听状态。

docker启动报错

Step 1 : FROM zhiyunmetis/metis-full
---> 1622911b6c2e
Step 2 : WORKDIR /metis
---> Using cache
---> b48ed2668c4c
Step 3 : ADD . /metis
---> Using cache
---> 6015ba1b8dfa
Step 4 : EXPOSE 80
---> Using cache
---> dc693d43038a
Step 5 : EXPOSE 8080
---> Using cache
---> e1c6442aff3d
Step 6 : RUN chmod +x /metis/init.sh
---> Using cache
---> a757a442b401
Step 7 : CMD /bin/sh /metis/init.sh
---> Using cache
---> 508e0c2c741b
Successfully built 508e0c2c741b
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint romantic_blackwell (41ec0f0ec4e29ceddc7ea463743ac87a349c8ccaee52d2c2fbae54eff099da2a): iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8080 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1).
[root@compute1 docker]# docker run -i -t -p80:80 -p8080:8080 local/metis-demo:1.0
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint pedantic_varahamihira (296d662bd2ef5a6d06613e93f356cc2f199129512cebdcbc09a35e2c244fc289): iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8080 -j DNAT --to-destination 172.17.0.2:8080 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1).
[root@compute1 docker]#

docker部署传参

为了方便metis-svr,metis-db,metis-web分布式部署,建议 web寻址svr,svr 寻址db,都以容器参数方式传入

启动服务端失败

执行命令时报错
python /data/Metis/app/controller/manage.py runserver {ip}:{port}

receive SIGCHLD
child process %s exit with exitcode %s 4721 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
receive SIGCHLD
child process %s exit with exitcode %s 4722 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
receive SIGCHLD
child process %s exit with exitcode %s 4724 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
receive SIGCHLD
child process %s exit with exitcode %s 4732 0
current process has no existing unwaited-for child processes.
handle SIGCHLD end
Performing system checksUnhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f7075217488>
Traceback (most recent call last):
  File "/root/django/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/root/django/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/root/django/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/root/django/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/root/django/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/root/django/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/root/django/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/root/django/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/django/django/urls/resolvers.py", line 559, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/root/django/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/root/django/django/urls/resolvers.py", line 552, in urlconf_module
    return import_module(self.urlconf_name)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/root/Metis/app/controller/settings/urls.py", line 18, in <module>
    from api import views as api_views
  File "/root/Metis/app/controller/api/views.py", line 20
    except Exception, ex:
                    ^
SyntaxError: invalid syntax

由于需要安装最新的django,必须使用python3.6,所以目前使用的是python 3.6。
是否是执行该启动服务脚本时必须用python2.7?

Metis离线部署的方案

1:问一下Metis离线部署的方案
因为我所在的传统企业,生产系统都不能连外网,
所以,使用不了在线安装方式;
2:我所在的传统企业都在用CentOS 6.5,是否也支持呀?

时间序列异常检测学件-诚意不足

看了Metis开源代码,初步感觉:工程化太弱,开源诚意不足,像是实习生写的代码

  • web 服务用到 python/django、mysql。python/django 有些代码非常冗余,例如 app/controller/api/views.py 可以使用 decorator 封装每个接口代码。另外 mysql 用来存储时序数据样本,但对于大量的时序数据,mysql 并不适合存储,从规划之初是否考虑到使用专门的时序数据库,例如 influxdb?

  • 做了 docker 部署,看起来是一个刚初学的人写的,一个 container 内用 nohup 方式启动 mysql,用 django 自带轻量级单线程的 runserver 命令启动 web服务,而且也是 nohup 方式,持久化数据也未挂载出来。

  • 这份开源的代码很难想象能承载 20w+ 服务器、240w 业务指标。所以,请问是不是专门为了开源,临时写的一套代码?除了算法部分 serveice 参考了公开的 icdm 2015 年论文外(详情见下一条),并没有什么新意。

  • 参考论文情况:Large-Scale Unusual Time Series Detection,后来作者又发了一篇相关的:Visualising Forecasting Algorithm Performance using Time Series Instance Spaces。python 中有一个很类似的库 tsfresh,这个库就是一个时间序列特征提取的库,作者的代码也是直接用的这个库的实现。Metis也是使用 sklearn + tsfresh 从中选了一些比较简单的特征,算法上并没有自己创新的地方。

  • 开源出来的只有离线检测(离线上传样本数据和训练模型),实时检测只是提供了一个对外的接口。

  • 工程化太弱,离实际生产环境感觉还有一段距离,项目开源的诚意并不足。

加载中

web 界面打开后一直在加载样本数据,不知道哪里出现问题

Metis离线部署的方案

1:问一下Metis离线部署的方案
因为我所在的传统企业,生产系统都不能连外网,
所以,使用不了在线安装方式;
2:我所在的传统企业都在用CentOS 6.5,是否也支持呀?

uwsgi部署失败

命令:uwsgi --http :9005 --chdir /root/metis/app/ --wsgi-file /root/metis/app/controller/settings/wsgi.py --master --processes 4
错误如下:
mapped 364600 bytes (356 KB) for 4 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
File "/root/metis/app/controller/settings/wsgi.py", line 16, in
application = get_wsgi_application()
File "/usr/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/lib/python2.7/site-packages/django/init.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/lib/python2.7/site-packages/django/conf/init.py", line 53, in getattr
self._setup(name)
File "/usr/lib/python2.7/site-packages/django/conf/init.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.7/site-packages/django/conf/init.py", line 97, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python2.7/importlib/init.py", line 37, in import_module
import(name)
ImportError: No module named settings.settings
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options

启动web服务器错误

我用的是python3.6,ubuntu系统

from ..api import views as api_vlews
ValueError: attempted relative import beyond top-level package
from ..api import views as api_views
提示文件等级问题,这是为什么,因为没有 安装使用centos,下载yum安装包?
使用绝对路径from app.controller.api import views
会显示没有model name ‘’app‘’ pip install app 以后 出现

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'controller'
这个错误,请问这是 为什么 安装环境 必须那样? 使用的django 但是 项目名字是appname是什么 而且他的等级问题为什么

跨站请求伪造

不建议Django 应用程序不启用 CSRF 中间件保护
app/controller/settings/settings.py 46
image

怎么实现异常检测的?

检测的流程是哪个脚本
这里只是查数据库 :
params.append(beg_limit)
params.append(limit)
command = 'SELECT id, view_id, view_name, attr_id, attr_name, UNIX_TIMESTAMP(time), data_c, data_b, data_a, mark_flag FROM anomaly WHERE time > from_unixtime(%s) and time < from_unixtime(%s) ' + query_str + 'LIMIT %s,
command_count = 'SELECT count(*) FROM anomaly WHERE time > from_unixtime(%s) and time < from_unixtime(%s) ' + query_str
length = self.__cur.execute(command, params)
abnormal_list = []
query_res = self.__cur.fetchmany(length)
for row in query_res:
abnormal_list.append({
"id": row[0],
"viewId": row[1],
"viewName": row[2],
"attrId": row[3],
"attrName": row[4],
"time": row[5],
"dataC": row[6].split(','),
"dataB": row[7].split(','),
"dataA": row[8].split(','),
"markFlag": row[9]
})
self.__cur.execute(command_count, params[:-2])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.