分析日誌並視覺化每天報錯計數

2021-10-08 06:47:22 字數 1704 閱讀 4127

系統生成的日誌以日期和報文展現,用正則匹配解析出來,日誌長這樣

先發乙個參考**

# -*- coding:utf-8 -*-

import re

def parsedate(l):

patternfortime = r'(\d[\d]\d[\d]\d[\d]?)'

for i in l:

m = re.search(patternfortime, i)

if m:

print(m.group(1))

if __name__ == '__main__':

l = ['永康市雅緻醫療器械****', '鄭雲燕', 'ii類:6863-16-定制式義齒', '原料藥', '津20170006', '2022/7/24', \

'2017/07/25', '2017-07-25', '2023年07月25', '2023年07月25日']

parsedate(l)

自己參照寫的

# -*- coding:utf-8 -*-

import re

from collections import counter

import numpy as np

import matplotlib.pyplot as plt

l =

patternfortime = r'(\d[\d]\d[\d]\d[\d]?\d)'

for j in range(1,30):

if j <10:

path = 'c:\\users\\fcx\\desktop\\0oa\\2020\\2020\\1\\trace_daily_2020-01-0'+str(j)+'.log'

else:

path = 'c:\\users\\fcx\\desktop\\0oa\\2020\\2020\\1\\trace_daily_2020-01-'+str(j)+'.log'

f = open(path,encoding = 'utf-8')

next(f)

for line_str in f:

a = counter(lists)

b = list(a.keys())

c = list(a.values())

print(b,c)

# del list

# x = np.arange(b)

# y = np.arange(c)

# x = np.arange(list(b))

# y = np.arange(list(c))

# x# y

plt.title("feb. error records")

plt.xlabel("time")

plt.ylabel("counts")

plt.plot(b,c)

plt.show()

輸出:

Python矩陣回歸並視覺化

from matplotlib import pyplot as plt import numpy as np from mpl toolkits.mplot3d import axes3d fig plt.figure figsize 10 6 ax axes3d fig 列出實驗資料 point...

python隨機漫步資料,並視覺化

randow walk.py內的 隨機漫步 from random import choice class randomwalk 乙個生成隨機漫步資料的類 def init self,num points 5000 初始化隨機漫步的屬性 self.num points num points 所有隨機...

mongo日誌視覺化

原始mongod.log格式 2020 11 26t21 33 45.896 0800 i network listener connection accepted from 10.10.6.192 52138 1663452 121 connections now open 2020 11 26t...