Compare commits

...

15 Commits
v0.1 ... master

Author SHA1 Message Date
pengln b5133e3bc3 增加uc01vn项目的filebeat采集处理器 2022-05-31 15:55:05 +08:00
pengln 2a086b7935 修订sublog判断不正确导致索引名称含有none的问题 2022-02-18 14:26:35 +08:00
pengln 431fd883d0 修订模板名称和模板模式不一致的问题 2022-02-18 14:19:39 +08:00
pengln c4a5e690e2 修复elastic_delays_metric_enabled属性始终渲染为False的问题 2022-02-15 17:51:59 +08:00
pengln 1d874245bd 修复elastic_delays_metric_enabled属性始终渲染为False的问题 2022-02-15 17:30:53 +08:00
pengln 6693204a3a 默认filebaet_ilm_enabled=yes
取消gw日志的延迟采集
2022-02-15 16:05:42 +08:00
pengln a48bfc9e1f 紧急修复配置模板文件语法错误 2022-02-15 15:55:04 +08:00
pengln f6c876d064 如果filebaet_ilm_enabled被设置为false则禁止ilm,这是为了兼容华为云的ES 2022-02-15 15:51:43 +08:00
pengln 0455b1d144 如果filebaet_ilm_enabled被设置为false则禁止ilm,这是为了兼容华为云的ES 2022-02-15 15:51:29 +08:00
pengln 85e4876338 将参数默认值从False改为no 2022-02-15 14:39:54 +08:00
pengln 7f03a7f4f5 # 关闭掉Filebeat本身的metrics日志输出
# 修订配置文件自动reload
2022-02-15 13:59:33 +08:00
pengln e9ec1f3367 [#1002039] Nginx日志采集过滤Countly日志文件 2022-02-15 11:21:23 +08:00
pengln 46e42aa987 #[1002041] 只给quick日志和gw日志开启elastic_delays检查 2022-02-15 11:12:33 +08:00
pengln 30ca92301c [#1002043] 通过强制filebeat注册ilm策略方式,修订意外丢失的ilm策略 2022-02-15 10:17:34 +08:00
pengln 92566348bc [#1002040] 合并Nginx日志的索引以项目和日期命名 2022-02-15 09:33:27 +08:00
5 changed files with 697 additions and 5 deletions

626
.gitignore vendored Normal file
View File

@ -0,0 +1,626 @@
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
[Ll]ogs/
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# ---> GitBook
# Node rules:
## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
## Dependency directory
## Commenting this out is preferred by some people, see
## https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git
node_modules
# Book build output
_book
# eBook build output
*.epub
*.mobi
*.pdf
# ---> TortoiseGit
# Project-level settings
/.tgitconfig
# ---> JENKINS_HOME
# Learn more about Jenkins and JENKINS_HOME directory for which this file is
# intended.
#
# http://jenkins-ci.org/
# https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
#
# Note: secret.key is purposefully not tracked by git. This should be backed up
# separately because configs may contain secrets which were encrypted using the
# secret.key. To back up secrets use 'tar -czf /tmp/secrets.tgz secret*' and
# save the file separate from your repository. If you want secrets backed up
# with configuration, then see the bottom of this file for an example.
# Ignore all JENKINS_HOME except jobs directory, root xml config, and
# .gitignore file.
# /*
/test/t*
!/jobs
!/.gitignore
!/*.xml
.git/
# Ignore all files in jobs subdirectories except for folders.
# Note: git doesn't track folders, only file content.
jobs/**
!jobs/**/
# Uncomment the following line to save next build numbers with config.
#!jobs/**/nextBuildNumber
# For performance reasons, we want to ignore builds in Jenkins jobs because it
# contains many tiny files on large installations. This can impact git
# performance when running even basic commands like 'git status'.
builds
indexing
# Exclude only config.xml files in repository subdirectories.
!config.xml
# Don't track workspaces (when users build on the master).
jobs/**/*workspace
# Security warning: If secrets are included with your configuration, then an
# adversary will be able to decrypt all encrypted secrets within Jenkins
# config. Including secrets is a bad practice, but the example is included in
# case someone still wants it for convenience. Uncomment the following line to
# include secrets for decryption with repository configuration in Git.
#!/secret*
# As a result, only Jenkins settings and job config.xml files in JENKINS_HOME
# will be tracked by git.
# ---> VisualStudioCode
.vscode/
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
[Bb]uild/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
[Tt]est/
[Tt]est/*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Nuget personal access tokens and Credentials
nuget.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
.idea/
*.sln.iml
# ---> SVN
.svn/

View File

@ -22,12 +22,14 @@ filebeat_logs:
index_prefix: "gw-nginx" index_prefix: "gw-nginx"
template_name: "gw-nginx-ug10cn" template_name: "gw-nginx-ug10cn"
template_pattern: "gw-nginx-*" template_pattern: "gw-nginx-*"
exclude_files: '_81\.log$' #[#1002039] Nginx日志采集过滤Countly日志文件
exclude_files: ['_81\.log$', '.*countly.*\.log$']
dissect_tokenizers: dissect_tokenizers:
- tokenizer: "/%{}/%{}/%{}/%{}_%{sublog}.log" - tokenizer: "/%{}/%{}/%{}/%{}_%{sublog}.log"
field_name: "log.file.path" field_name: "log.file.path"
filebeat_older_dir: "/data/opt/filebeat/{{ instance_name }}" filebeat_older_dir: "/data/opt/filebeat/{{ instance_name }}"
filebeat_older_data_dir: data filebeat_older_data_dir: data
filebaet_ilm_enabled: yes
manager: manager:
paths: paths:
- "/data/game/htdocs/center/manager/storage/cp/logs/*.log" - "/data/game/htdocs/center/manager/storage/cp/logs/*.log"
@ -38,6 +40,7 @@ filebeat_logs:
sublog: cp sublog: cp
filebeat_older_dir: "/data/opt/filebeat/{{ instance_name }}" filebeat_older_dir: "/data/opt/filebeat/{{ instance_name }}"
filebeat_older_data_dir: data2 filebeat_older_data_dir: data2
filebaet_ilm_enabled: yes
quick: quick:
paths: paths:
- "/data/game/sync/quick/filebeat/*.txt" - "/data/game/sync/quick/filebeat/*.txt"
@ -53,4 +56,7 @@ filebeat_logs:
layouts: layouts:
- '2006-01-02 15:04:05' - '2006-01-02 15:04:05'
filebeat_older_dir: "/data/opt/filebeat/quick" filebeat_older_dir: "/data/opt/filebeat/quick"
filebeat_older_data_dir: data filebeat_older_data_dir: data
filebaet_ilm_enabled: yes
#[1002041] 只给quick日志elastic_delays检查
elastic_delays_metric_enabled: yes

View File

@ -0,0 +1,42 @@
function process(event) {
var msg = event.Get("message");
var i
msg = msg.replace("/\r/g", "");
msg = msg.replace("/\n/g", "");
msg = msg.replace("/\r/\n/g", "");
var fields = msg.split("\t");
if (Number(fields[1]) == 64) {
// log_id = 64的日志是子后台同步过来的需要特殊处理掉
event.Cancel(); return;
}
for (i = 0; i < 25; i++) {
if (fields[i] == null) {
fields[i] = "";
} else if (fields[i].trim() == "-") {
fields[i] = "";
} else {
fields[i] = fields[i].trim();
}
}
event.Put("log_datetime", fields[0]);
event.Put("log_id", fields[1]);
event.Put("role_id", fields[2]);
event.Put("role_name", fields[3]);
event.Put("account_id", fields[4]);
var ws = fields[4].split("_") // 从account_id分离spid和channel
// account_id中只有第一个部分是描述spid的故spid和channel使用相同的信息填充
event.Put("spid", ws[0]);
event.Put("channel", ws[0]);
for (i = 5; i < fields.length; i++) {
event.Put("col" + (i - 4), fields[i]);
}
return event;
}

View File

@ -1,7 +1,17 @@
# 关闭掉Filebeat本身的metrics日志输出
logging.metrics.enabled: false
# 修订配置文件自动reload
filebeat.config.inputs:
enabled: true
path: ${path.config}/filebeat.yml
reload.enabled: true
reload.period: 10s
logging.json: false logging.json: false
queue.mem: queue.mem:
events: {{ filebeat_queue_mem_events | default(1024) }} events: {{ filebeat_queue_mem_events | default(8192) }}
flush.min_events: {{ filebeat_queue_mem_flush_min_event | default(512) }} flush.min_events: {{ filebeat_queue_mem_flush_min_event | default(512) }}
filebeat.inputs: filebeat.inputs:
@ -30,7 +40,12 @@ filebeat.config.modules:
reload.enabled: false reload.enabled: false
# ======================= Elasticsearch template setting ======================= # ======================= Elasticsearch template setting =======================
#[#1002043] 通过强制filebeat注册ilm策略方式修订意外丢失的ilm策略。
#如果filebaet_ilm_enabled被设置为false则禁止ilm这是为了兼容华为云的ES
setup.ilm.enabled: false setup.ilm.enabled: false
setup.ilm.policy_name: "{{ logs[log_type]['setup_ilm_policy_name'] | default('gw-nginx-ug10') }}"
setup.ilm.check_exists: false
setup.template.name: "{{ logs[log_type]['template_name'] }}" setup.template.name: "{{ logs[log_type]['template_name'] }}"
setup.template.pattern: "{{ logs[log_type]['template_pattern'] }}" setup.template.pattern: "{{ logs[log_type]['template_pattern'] }}"
@ -47,7 +62,10 @@ setup.kibana:
{% if 'output' not in logs[log_type] or logs[log_type]['output'] == 'elastic' %} {% if 'output' not in logs[log_type] or logs[log_type]['output'] == 'elastic' %}
output.elasticsearch: output.elasticsearch:
hosts: {{ logs[log_type]['es_hosts'] }} hosts: {{ logs[log_type]['es_hosts'] }}
{% if 'sublog' in logs[log_type] and logs[log_type]['sublog'] -%} #[#1002040] 如果sublog字段配置为none则忽略索引名称中的sublog字段
{% if 'sublog' in logs[log_type] and logs[log_type]['sublog'] == 'none' -%}
index: "{{ logs[log_type]['index_prefix'] }}-{{ instance_name }}-%{+yyyy.MM.dd}"
{% elif 'sublog' in logs[log_type] and logs[log_type]['sublog'] -%}
index: "{{ logs[log_type]['index_prefix'] }}-{{ instance_name }}-{{ logs[log_type]['sublog'] }}-%{+yyyy.MM.dd}" index: "{{ logs[log_type]['index_prefix'] }}-{{ instance_name }}-{{ logs[log_type]['sublog'] }}-%{+yyyy.MM.dd}"
{% else -%} {% else -%}
index: "{{ logs[log_type]['index_prefix'] }}-{{ instance_name }}-%{[sublog]}-%{+yyyy.MM.dd}" index: "{{ logs[log_type]['index_prefix'] }}-{{ instance_name }}-%{[sublog]}-%{+yyyy.MM.dd}"

View File

@ -6,4 +6,4 @@ metric_host: {{ filebeat_monitor_sock | default('./filebeat_monitor.sock') }}
push_gateway_url: {{ filebeat_monitor_push_gateway | default('') }} push_gateway_url: {{ filebeat_monitor_push_gateway | default('') }}
push_gateway_lifecycle: {{ filebeat_monitor_push_lifecycle | default(5) }} push_gateway_lifecycle: {{ filebeat_monitor_push_lifecycle | default(5) }}
log_path: {{ filebeat_monitor_log_path | default('logs/filebeat_monitor.log') }} log_path: {{ filebeat_monitor_log_path | default('logs/filebeat_monitor.log') }}
elastic_delays_metric_enabled: {{ elastic_delays_metric_enabled | default('False')}} elastic_delays_metric_enabled: {{ filebeat_logs[log_type]['elastic_delays_metric_enabled'] | default('False')}}