python实现某天每5分钟提取一条数据

本文介绍如何使用Python编写定时任务,每隔5分钟从ELK(Elasticsearch、Logstash、Kibana)堆栈中提取数据。通过实例代码展示具体的实现步骤,帮助读者理解如何利用Python高效地获取和处理实时日志信息。
摘要由CSDN通过智能技术生成
方法一:
from elasticsearch import Elasticsearch
import os

es = Elasticsearch(['localhost'], http_auth=('', ''), port=9273, timeout=50000)
def write_start_data(time_, time_list, month, file_name, iptvaccount):
    write_fact_path = "E:\\公司\\案例数据采集\\olt告警案例分析\\{0}\\{1}_{2}.txt".format(time_, iptvaccount, file_name)
    f = open(write_fact_path, "w")
    for key, value in time_list.items():
        start = key.format(day, start_hour, month, end_hour)
        end = value.format(day, start_hour, month, end_hour)
        hour_min = start.split()[1]
        if hour_min == "23:55":
            end = value.format(day_next,start_hour,month,end_hour)
        rs = get_iptv_monitor_start_data(time_, start, end, iptvaccount)
        for hit in rs['hits']['hits']:
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值