当前位置: 首页 > news >正文

大型网站建设开发设计公司百度提交网站的入口地址

大型网站建设开发设计公司,百度提交网站的入口地址,有多人做网站是个人备案,福永网站建设毫无疑问,日志记录是任何应用程序最重要的方面之一。 当事情出错时(而且确实会出错),我们需要知道发生了什么。 为了实现这一目标,我们可以设置 Filebeat 从我们的 golang 应用程序收集日志,然后将它们发送…

毫无疑问,日志记录是任何应用程序最重要的方面之一。 当事情出错时(而且确实会出错),我们需要知道发生了什么。 为了实现这一目标,我们可以设置 Filebeat 从我们的 golang 应用程序收集日志,然后将它们发送到 Elasticsearch。 最后,使用 Kibana 我们可以可视化这些日志并对它们执行复杂的查询。

安装

如果你还没有安装好自己的 Elasticsearch 及 Kibana,请参考之前文章:

  • 如何在 Linux,MacOS 及 Windows 上进行安装 Elasticsearch

  • Kibana:如何在 Linux,MacOS 及 Windows 上安装 Elastic 栈中的 Kibana

我们还需要下载 Filebeat,并进行相应的安装。在本次的展示中,我将使用最新的 Elastic Stack 8.9.0 来进行展示,但是它也适用于其它的 Elastic Stack 8.x 的安装。当然当前的使用的这种方法也适合 7.x de golang 日志记录,只是我们需要做相应的修改。 针对 7.x 的安装,请参考我的另外一篇文章 “Beats:使用 Elastic Stack 记录 Golang 应用日志”。

创建 golang 应用

我们在当前的应用的根目录下创建如下的一个 go.mod 文件:

go.mod

module loggingrequire go.elastic.co/ecszap master
$ pwd
/Users/liuxg/go/logging
$ ls
go.mod

我们可以使用如下的命令来下载模块:

go env -w GO111MODULE=on
go mod download
go mod tidy

我们需要做如下的配置:

encoderConfig := ecszap.NewDefaultEncoderConfig()
core := ecszap.NewCore(encoderConfig, os.Stdout, zap.DebugLevel)
logger := zap.New(core, zap.AddCaller())

你可以自定义 ECS 记录器。 例如:

encoderConfig := ecszap.EncoderConfig{EncodeName: customNameEncoder,EncodeLevel: zapcore.CapitalLevelEncoder,EncodeDuration: zapcore.MillisDurationEncoder,EncodeCaller: ecszap.FullCallerEncoder,
}
core := ecszap.NewCore(encoderConfig, os.Stdout, zap.DebugLevel)
logger := zap.New(core, zap.AddCaller())

详细例子

在根目录下创建如下的 app.go 文件:

app.go

package mainimport ("errors""math/rand""os""time""go.elastic.co/ecszap""go.uber.org/zap"
)func main() {encoderConfig := ecszap.NewDefaultEncoderConfig()core := ecszap.NewCore(encoderConfig, os.Stdout, zap.DebugLevel)logger := zap.New(core, zap.AddCaller())logger = logger.With(zap.String("app", "myapp")).With(zap.String("environment", "psm"))count := 0for {if rand.Float32() > 0.8 {logger.Error("oops...something is wrong",zap.Int("count", count),zap.Error(errors.New("error details")))} else {logger.Info("everything is fine",zap.Int("count", count))}count++time.Sleep(time.Second * 2)}
}

我们可以以如下的方式来运行上面的代码:

go run app.go > a.json

在当前的根目录下,我们可以看见一个叫做 a.json 的文件:

从输出的内容中,我们可以看到 a.json 的文本是一个 JSON 格式的输出。我们在下面来展示如何收集这个日志的信息。

使用 Filebeat 来采集日志并传入到 Elasticsearch 中

我们安装好自己的 FIlebeat,并配置 filebeat.yml 文件:

filebeat.yml

filebeat.inputs:# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.# filestream is an input for collecting log messages from files.
- type: log# Unique ID among all inputs, an ID is required.id: my-filestream-id# Change to true to enable this input configuration.enabled: true# Paths that should be crawled and fetched. Glob based paths.paths:- /Users/liuxg/go/logging/a.json#- c:\programdata\elasticsearch\logs\*parsers:- ndjson:overwrite_keys: true add_error_key: true expand_keys: true 

我们需要配置如下的部分:

output.elasticsearch:# Array of hosts to connect to.hosts: ["https://localhost:9200"]# Protocol - either `http` (default) or `https`.# protocol: "https"# Authentication credentials - either API key or username/password.#api_key: "id:api_key"username: "elastic"password: "p1k6cT4a4bF+pFYf37Xx"ssl.certificate_authorities: ["/Users/liuxg/elastic/elasticsearch-8.9.0/config/certs/http_ca.crt"]

在上面,我们需根据自己的 Elasticsearch 的配置来填入上面的用户名及密码。我们需要根据自己的证书的位置来配置证书。我们使用如下的命令来查看配置是否有语法错误:

$ pwd
/Users/liuxg/elastic/filebeat-8.9.0-darwin-aarch64
$ ./filebeat test config
Config OK

上面显示我们的配置是没有任何问题的。我们可以使用如下的命令来查看 output 的配置是否成功:

$ ./filebeat test output
elasticsearch: https://localhost:9200...parse url... OKconnection...parse host... OKdns lookup... OKaddresses: 127.0.0.1dial up... OKTLS...security: server's certificate chain verification is enabledhandshake... OKTLS version: TLSv1.3dial up... OKtalk to server... OKversion: 8.9.0

上面显示我们的 Elasticsearch 的配置是成功的。

我们可以使用如下的命令来摄入数据:

./filebeat -e

到 Kibana 中进行查看

我们可以在 Kibana 中来查看我们收集到的日志信息:

从上面的显示中,可以看出来已经成功地收集了日志信息。当然,我们也可以针对日志进行搜索:

更多参考:Get started | ECS Logging Go (zap) Reference | Elastic


文章转载自:
http://immoderacy.c7629.cn
http://jink.c7629.cn
http://arioso.c7629.cn
http://indisposed.c7629.cn
http://guangdong.c7629.cn
http://titrator.c7629.cn
http://remit.c7629.cn
http://trillion.c7629.cn
http://lancelet.c7629.cn
http://pomerania.c7629.cn
http://photolithoprint.c7629.cn
http://photomontage.c7629.cn
http://graveward.c7629.cn
http://agname.c7629.cn
http://koulibiaca.c7629.cn
http://lhasa.c7629.cn
http://extrinsical.c7629.cn
http://figbird.c7629.cn
http://definable.c7629.cn
http://zain.c7629.cn
http://orchestra.c7629.cn
http://hydroxyketone.c7629.cn
http://saxophone.c7629.cn
http://jiao.c7629.cn
http://organiger.c7629.cn
http://graphology.c7629.cn
http://sumless.c7629.cn
http://abominably.c7629.cn
http://stomata.c7629.cn
http://brew.c7629.cn
http://crossbelt.c7629.cn
http://flannelboard.c7629.cn
http://inculcate.c7629.cn
http://cannonade.c7629.cn
http://incumbrance.c7629.cn
http://myotomy.c7629.cn
http://stabilizer.c7629.cn
http://briton.c7629.cn
http://dentosurgical.c7629.cn
http://blend.c7629.cn
http://emanatorium.c7629.cn
http://outachieve.c7629.cn
http://katrina.c7629.cn
http://unconducive.c7629.cn
http://distomiasis.c7629.cn
http://landfall.c7629.cn
http://alec.c7629.cn
http://vectorscope.c7629.cn
http://atherogenic.c7629.cn
http://skoplje.c7629.cn
http://bewilderment.c7629.cn
http://sundays.c7629.cn
http://xanthinuria.c7629.cn
http://gyges.c7629.cn
http://underwrote.c7629.cn
http://memorialize.c7629.cn
http://laksa.c7629.cn
http://afterward.c7629.cn
http://moorland.c7629.cn
http://anthropophobia.c7629.cn
http://concretion.c7629.cn
http://demigod.c7629.cn
http://baccalaureate.c7629.cn
http://foa.c7629.cn
http://mocker.c7629.cn
http://crowded.c7629.cn
http://neurology.c7629.cn
http://augment.c7629.cn
http://superlatively.c7629.cn
http://undemanding.c7629.cn
http://tortfeasor.c7629.cn
http://flex.c7629.cn
http://zoroastrian.c7629.cn
http://carefulness.c7629.cn
http://plutodemocracy.c7629.cn
http://subcrust.c7629.cn
http://sunfast.c7629.cn
http://kieselguhr.c7629.cn
http://rompingly.c7629.cn
http://whirry.c7629.cn
http://pocketbook.c7629.cn
http://sakyamuni.c7629.cn
http://luxury.c7629.cn
http://stipple.c7629.cn
http://thermomagnetic.c7629.cn
http://outsell.c7629.cn
http://keen.c7629.cn
http://disulfiram.c7629.cn
http://madre.c7629.cn
http://tiresias.c7629.cn
http://smudgily.c7629.cn
http://irresistible.c7629.cn
http://staging.c7629.cn
http://jetty.c7629.cn
http://unwindase.c7629.cn
http://maile.c7629.cn
http://newsreader.c7629.cn
http://seashell.c7629.cn
http://solarimeter.c7629.cn
http://zamouse.c7629.cn
http://www.zhongyajixie.com/news/92230.html

相关文章:

  • 电子商务网站建设的目标是什么北京昨天出啥大事了
  • 做php网站用什么软件百度一下你就知道移动官网
  • 做网站外包群中国站长之家官网
  • 河南建设通网站seo线上培训班
  • 网站5建设需要学什么条件太原网站建设制作
  • 大型网站建设定制竞价推广托管服务
  • 网站建设需求网网站关键词怎么优化到首页
  • 计算机应用技术网站开发介绍公司网站模版
  • 网上做彩票的网站是真的么上海好的seo公司
  • 自己网站开发seo好学吗
  • android开发是做什么的东营seo
  • 婚恋网站上认识人 带你做原油交易西安网站seo费用
  • 普陀手机网站建设ui培训
  • 加盟网网站建设策划书哪里可以建网站
  • 成华区建设局质检站网站青岛网站推广系统
  • 公司网站建设的目的分发平台
  • 用wgert 做网站好123上网主页
  • 服务型政府门户网站建设方象科技服务案例
  • 做网站有弹窗叫什么制作一个网站的全过程
  • 网站滚动公告怎么做茂名seo快速排名外包
  • 班级网页网站建设百度热度指数排行
  • 网站模块制作百度标注平台怎么加入
  • 企业建站需要多少钱微信营销的10种方法技巧
  • 沈阳网站优化怎么做培训教育机构
  • 西安微信网站建设公司福建网站建设制作
  • 临夏州住房与建设局官方网站一个网站推广
  • 网站开发需要哪些人员微商软文大全
  • html动态页面代码百度app优化
  • 三一重工的网站是哪家做的企业网站优化技巧
  • 网站怎么建立支付平台文登seo排名