小编ali*_*227的帖子

无法将跟踪导出到 Kubernetes 上的 OpenTelemetry Collector

我正在使用 opentelemetry-ruby otlp 导出器进行自动检测: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/exporter/otlp

otel 收集器作为守护进程安装: https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-collector

我正在尝试让 OpenTelemetry 收集器从 Rails 应用程序收集跟踪。两者都在同一集群中运行,但在不同的命名空间中。

我们已在应用程序中启用自动检测,但 Rails 日志当前显示以下错误:

E, [2022-04-05T22:37:47.838197 #6] ERROR -- : OpenTelemetry error: Unable to export 499 spans

我在应用程序中设置了以下环境变量:

OTEL_LOG_LEVEL=debug
OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4318
Run Code Online (Sandbox Code Playgroud)

我无法确认应用程序可以与此端口上的收集器 Pod 进行通信。从 Rails/Ruby 应用程序中获取此地址会返回“连接被拒绝”。但是我可以使用curlhttp://<OTEL_POD_IP>:4318来返回404 页面未找到。

从 Pod 内部:

# curl http://localhost:4318/
curl: (7) Failed to connect to localhost port 4318: Connection refused

# curl http://10.1.0.66:4318/
404 page not found
Run Code Online (Sandbox Code Playgroud)

此 Helm Chart 创建了一个守护进程集,但没有正在运行的服务。我需要启用一些设置才能使其正常工作吗?

我确认 otel-collector 正在集群中的每个节点上运行,并且 daemonset 的 HostPort 设置为 4318。

ruby-on-rails exporter kubernetes open-telemetry

5
推荐指数
1
解决办法
1万
查看次数

如何从 ansible 的模板编写一个漂亮的 JSON 文件?

我正在尝试使用 jinja2 模板编写一个配置文件并将文件保存为 .json 并对其进行漂亮的格式化。

如何将输出文件保存为变量,然后使用 to_nice_json 将其格式化为 JSON?这个剧本是从另一个主要剧本中调用的角色的一部分。目前,它将配置文件写入 Windows 主机,但未格式化为 JSON。

---
#Write config file
- name: Deploy configuration file
  template: src=templates/config.j2 dest="C:\\SomeDir\\
{{web_app.name}}_config.json"
Run Code Online (Sandbox Code Playgroud)

json jinja2 ansible

2
推荐指数
1
解决办法
1万
查看次数

使用 jq 将新的根级别属性添加到 JSON 对象

我有一个大型 JSON 文件(大约 7K 行),其中包含深度嵌套的项目,其中缺少collection我需要添加的必需属性。当前 JSON 对象:

{
  "item": [
        {
          "id": "123",
          "name": "Customer",
          "item": [
              {
                 "id": "456",
                 "name": "Retrieve a customer"
....
Run Code Online (Sandbox Code Playgroud)

使用 bash 脚本,我需要添加一个像这样的顶级属性"collection" ,其中仍然包含相同的嵌套项。这是我想要的结果:

{
  "collection": {
    "item": [
         {
           "id": "123",
           "name": "Customer",
           "item": [
               {
                "id": "456",
                "name": "Retrieve a customer",
....       
Run Code Online (Sandbox Code Playgroud)

在 JSON 对象的末尾,我还需要}在文件末尾为新添加的collection:键匹配的右大括号。有没有办法用 JQ 做到这一点?

json jq

2
推荐指数
1
解决办法
1571
查看次数