首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >APM Go代理未向APM服务器发送数据

APM Go代理未向APM服务器发送数据
EN

Stack Overflow用户
提问于 2020-08-19 13:06:10
回答 1查看 953关注 0票数 0

我已经启动并运行了一个Elastic APM-Server,它已经成功地与Elasticsearch建立了连接。

然后我安装了一个Elastic APM Go代理:

代码语言:javascript
复制
go get -u go.elastic.co/apm

它返回以下内容:

代码语言:javascript
复制
finding go.elastic.co/apm v1.8.0
finding github.com/stretchr/testify v1.4.0
finding github.com/prometheus/procfs v0.0.3
finding github.com/google/go-cmp v0.3.1
finding github.com/armon/go-radix v1.0.0
finding github.com/santhosh-tekuri/jsonschema v1.2.4
finding github.com/cucumber/godog v0.8.1
finding golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e
finding go.elastic.co/fastjson v1.0.0
finding github.com/google/go-cmp v0.5.1
finding github.com/prometheus/procfs v0.1.3
finding golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
finding golang.org/x/sys latest
finding github.com/elastic/go-sysinfo v1.1.1
finding golang.org/x/sync latest
finding golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e
finding github.com/stretchr/testify v1.6.1
finding go.elastic.co/fastjson v1.1.0
finding github.com/cucumber/godog v0.10.0
finding github.com/stretchr/objx v0.3.0
finding github.com/elastic/go-sysinfo v1.4.0
finding gopkg.in/yaml.v2 v2.2.2
finding github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901
finding golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
finding github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0
finding github.com/elastic/go-windows v1.0.0
finding golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae
finding golang.org/x/xerrors latest
finding gopkg.in/yaml.v2 v2.3.0
finding golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5
finding github.com/yuin/goldmark v1.1.27
finding github.com/cucumber/messages-go/v10 v10.0.3
finding gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
finding howett.net/plist v0.0.0-20181124034731-591f970eefbb
finding golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
finding gopkg.in/check.v1 latest
finding golang.org/x/mod v0.2.0
finding golang.org/x/tools latest
finding github.com/hashicorp/go-memdb v1.2.1
finding golang.org/x/net latest
finding github.com/cucumber/gherkin-go/v11 v11.0.0
finding github.com/joeshaw/multierror latest
finding golang.org/x/crypto latest
finding github.com/yuin/goldmark v1.1.32
finding github.com/elastic/go-windows v1.0.1
finding golang.org/x/mod v0.3.0
finding golang.org/x/text v0.3.3
finding howett.net/plist latest
finding golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
finding golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
finding golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
finding golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
finding golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
finding golang.org/x/net v0.0.0-20200625001655-4c5254603344
finding github.com/kr/pretty v0.2.1
finding github.com/jessevdk/go-flags v1.4.0
finding github.com/kr/text v0.2.0
finding github.com/kr/pty v1.1.8
finding github.com/hashicorp/go-immutable-radix v1.2.0
finding github.com/hashicorp/golang-lru v0.5.4
finding github.com/yuin/goldmark v1.2.1
finding github.com/aslakhellesoy/gox v1.0.100
finding gopkg.in/yaml.v3 latest
finding gopkg.in/yaml.v2 v2.2.8
finding golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
finding github.com/gogo/protobuf v1.3.1
finding github.com/gofrs/uuid v3.2.0+incompatible
finding github.com/stretchr/testify v1.5.1
finding github.com/creack/pty v1.1.7
finding github.com/creack/pty v1.1.9
finding github.com/cucumber/messages-go/v10 v10.0.1
finding github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e
finding github.com/hashicorp/go-uuid v1.0.0
finding github.com/hashicorp/go-version v1.0.0
finding github.com/mitchellh/iochan v1.0.0
finding gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
finding github.com/kr/pretty v0.2.0
finding github.com/niemeyer/pretty latest
finding github.com/hashicorp/go-uuid v1.0.2
finding github.com/hashicorp/go-version v1.2.1
finding github.com/creack/pty v1.1.11
finding github.com/kisielk/errcheck v1.2.0
finding github.com/gofrs/uuid v3.3.0+incompatible
finding github.com/kisielk/errcheck v1.4.0
finding golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563
finding golang.org/x/tools v0.0.0-20200619180055-7c47624df98f
downloading go.elastic.co/apm v1.8.0
extracting go.elastic.co/apm v1.8.0
downloading github.com/elastic/go-sysinfo v1.4.0
downloading golang.org/x/sys v0.0.0-20200819035508-9a32b3aa38f5
downloading go.elastic.co/fastjson v1.1.0
downloading github.com/armon/go-radix v1.0.0
extracting go.elastic.co/fastjson v1.1.0
extracting github.com/armon/go-radix v1.0.0
extracting github.com/elastic/go-sysinfo v1.4.0
downloading howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5
downloading github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901
downloading github.com/prometheus/procfs v0.1.3
extracting github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901
extracting howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5
extracting github.com/prometheus/procfs v0.1.3
extracting golang.org/x/sys v0.0.0-20200819035508-9a32b3aa38f5

然后设置ELASTIC_APM_SERVER_URLELASTIC_APM_SERVICE_NAME

代码语言:javascript
复制
export ELASTIC_APM_SERVER_URL=http://my-apm-server-url
export ELASTIC_APM_SERVICE_NAME=agent-name

但是,我没有看到代理在APM仪表板中注册。

它没有向APM服务器发送任何数据。

如何确保代理正在运行?如何检查代理日志,了解它无法连接到APM服务器的原因?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-19 13:40:43

既然你在上面没有提到:你有没有检测Go应用程序?Elastic APM Go "Agent“是一个用于检测应用程序源代码的包。它不是一个独立的进程,而是运行在您的应用程序中。

所以,首先(如果你还没有)检测你的应用程序。请参阅https://www.elastic.co/guide/en/apm/agent/go/current/getting-started.html#instrumenting-source

下面是一个使用Echoapmechov4工具模块的示例web服务器:

代码语言:javascript
复制
package main

import (
        "fmt"
        "net/http"

        echo "github.com/labstack/echo/v4"

        "go.elastic.co/apm/module/apmechov4"
)

func main() {
        e := echo.New()
        e.Use(apmechov4.Middleware())
        e.GET("/hello/:name", func(c echo.Context) error {
                fmt.Println(c.Param("name"))
                return nil
        })
        http.ListenAndServe(":8080", e)
}

如果你运行它并向http://localhost:8080/hello/world发送一些请求,你应该很快就会在Kibana的APM应用程序中看到请求。

如果您在Kibana中仍然看不到任何内容,可以使用https://www.elastic.co/guide/en/apm/agent/go/current/troubleshooting.html#agent-logging启用日志记录。如果代理能够成功地将数据发送到服务器,您可以看到以下内容:

代码语言:javascript
复制
$ ELASTIC_APM_LOG_FILE=stderr ELASTIC_APM_LOG_LEVEL=debug go run main.go
{"level":"debug","time":"2020-08-19T13:33:28+08:00","message":"sent request with 3 transactions, 0 spans, 0 errors, 0 metricsets"}
{"level":"debug","time":"2020-08-19T13:33:46+08:00","message":"gathering metrics"}
{"level":"debug","time":"2020-08-19T13:33:56+08:00","message":"sent request with 0 transactions, 0 spans, 0 errors, 3 metricsets"}

另一方面,如果服务器不可访问,您将看到如下所示:

代码语言:javascript
复制
{"level":"error","time":"2020-08-19T13:38:01+08:00","message":"config request failed: sending config request failed: Get \"http://localhost:8200/config/v1/agents?service.name=main\": dial tcp 127.0.0.1:8200: connect: connection refused"}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63480314

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档