首页 文章 精选 留言 我的

精选列表

搜索[类],共10000篇文章
优秀的个人博客,低调大师

filebeat-kafka-logstash-elasticsearch日志收集[中文时区问题、自己创建type类index]

logstash配置文件如下: 点击(此处)折叠或打开 input{ kafka{ bootstrap_servers => "xxxx:9092,xxxx:9092,dw72.xxxx.:9092,...." group_id => "xxxx_service_server_logstash" topics => ["xxxx_service_server_error", "xxxx_service_server_runtime"] auto_offset_reset => latest codec => "json" consumer_threads => 10 auto_commit_interval_ms => 500 } } filter { grok { #patterns_dir => ["./patterns"] match => { "message" => "%{TIMESTAMP_ISO8601:logdatetime}" } } date { match => [ "logdatetime", "yyyy-MM-dd HH:mm:ss"] target => "@timestamp" # timezone => "Asia/Shanghai" timezone => "+00:00" locale => "en" } } output{ elasticsearch{ hosts => ["192.168.1.89:9200"] action => "index" index => "%{[type]}-%{+YYYY.MM.dd}" flush_size => 8000 } } 主要关注两个问题: 1.event的timestamp问题,中国区会显示比实际的时间早8个小时(一般不建议修改时间,国际标准,在kibana中做处理。),这里只有国内的服务器,显示为区域时间比较好看,所以我就改了。 2.es 的index根据filebeat中的document_type自动创建index。

优秀的个人博客,低调大师

Android ThreadUtil 线程公共类,判断是否在主线程/ 子线程执行 相关操作

前言:通常,我们写的公共的模块给别人用,但是这个模块又必须在特定的线程中执行。 比如,一个加载网络图片的的方法,需要在子线程中执行。 /** * 加载网络图片 */ private void loadImage() { try { //用延时3秒操作来模拟网络操作 Thread.sleep( 3000 ); } catch (InterruptedException e) { e.printStackTrace(); } } 但是其他的同事在使用的时候,可能一不小心就在主线程中执行了 loadImage() 方法。这样就势必造成了界面卡顿。 为了避免这种情况,我们需要一个线程判断的工具 ThreadUtil 来帮助我们处理。 当前线程是主线程,抛出异常,不去加载 当前线程是子线程,继续执行,完成加载 package com.app; import android.os.Looper; /** * Created by ${zyj} on 2016/6/7. */ public class ThreadUtil { /** * Throws an {@link java.lang.IllegalArgumentException} if called on a thread other than the main thread. */ public static void assertMainThread() { if (!isOnMainThread()) { throw new IllegalArgumentException("You must call this method on the main thread"); } } /** * Throws an {@link java.lang.IllegalArgumentException} if called on the main thread. */ public static void assertBackgroundThread() { if (!isOnBackgroundThread()) { throw new IllegalArgumentException("YOu must call this method on a background thread"); } } /** * Returns {@code true} if called on the main thread, {@code false} otherwise. */ public static boolean isOnMainThread() { return Looper.myLooper() == Looper.getMainLooper(); } /** * Returns {@code true} if called on the main thread, {@code false} otherwise. */ public static boolean isOnBackgroundThread() { return !isOnMainThread(); } } 然后我们把 loadImage() 修改一下,就成了 /** * 加载网络图片 */ private void loadImage() { //判断是否在子线程。 子线程:继续执行 主线程:抛出异常 ThreadUtil.assertBackgroundThread(); try { //用延时3秒操作来模拟网络操作 Thread.sleep( 3000 ); } catch (InterruptedException e) { e.printStackTrace(); } } 可以看到在 loadImage() 方法中多了一句: ThreadUtil.assertBackgroundThread(); 在assertBackgroundThread() 方法里,判断如果不是子线程就直接抛出"YOu must call this method on a background thread" 正确的调用应该是:在子线程中调用 loadImage() ,比如: new Thread(new Runnable() { @Override public void run() { loadImage(); } }).start(); 总结: ThreadUitl 是参考图片加载框架Glide写的 . ThreadUtil.assertBackgroundThread(); 要求在子线程中执行 ThreadUtil.assertMainThread() ; 要求在主线程运行 代码示例已上传到 github:https://github.com/zyj1609wz/ZUtils

优秀的个人博客,低调大师

网络监控数据用于安全预警:五类信号、检测能力与落地三步

异常行为最终会落到流量、设备状态或访问记录上,而这些正是网络监控持续采集的数据。传统边界设备与固定规则擅长拦截已知模式,对幅度小、节奏慢、贴着正常形态走的异常不敏感。把监控体系补上"形态是否变了"的观察能力,是多数企业成本最低的升级路径——数据不用重新采,缺的是口径与流程。

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码