首页 > 解决方案 > k8s 上的自动 elastic-apm .Net-Agent 配置

问题描述

我想自动将弹性凭据提供给我在同一个 k8s 集群上运行的 .net-Agent。

为了获取密码,我使用了他们文档中的以下脚本:

USERNAME="elastic"
PW=$(kubectl get secret "$NAME-es-elastic-user" -o go-template='{{.data.elastic | base64decode }}')

在他们的文档中,他们提到我可以使用凭据作为 API 密钥

... where {credentials} is the base64 encoding of id and api_key joined by a colon.

Alternatively, you can create a user and use their username and password to authenticate API access: -u $USER:$PASSWORD.

我尝试使用elastic:generatedpassword和 base64 编码的字符串相同。两者都不起作用并给出(“语法”或身份验证)错误:

fail: Elastic.Apm[0]
      {PayloadSenderV2} Failed sending event. Events intake API absolute URL: https://elastic-apm-http:8200/intake/v2/events. APM Server response: status code: Unauthorized, content: 
      {"error":"authentication failed: illegal base64 data at input byte 7"}

fail: Elastic.Apm[0]
      {PayloadSenderV2} Failed sending event. Events intake API absolute URL: https://elastic-apm-http:8200/intake/v2/events. APM Server response: status code: Unauthorized, content: 
      {"error":"authentication failed"}

所以我认为我可能误读了文档,并且密码身份验证不是Authorization: ApiKey {credentials}标题中给出的通过,而是基本身份验证。(但是我不知道如何在 .net 代理中进行设置)另一种解决方案是使用 API 密钥。(在这里我也没有找到如何在 k8s 中获取它们的任何资源。但是我找到了一个用于创建密钥的 http-API——这可能是一个复杂的解决方法)

我正在寻找正确的(最好是最简单的)解决方案来获取 k8s 集群上的 elastic-apm 代理的配置。

标签: elasticsearchkuberneteselastic-apm

解决方案


推荐阅读