gpt4 book ai didi

keycloak - 设置 Keycloak 导出器以与 Prometheus 一起工作

转载 作者:行者123 更新时间:2023-12-04 15:49:03 24 4
gpt4 key购买 nike

我正在尝试为 Keycloak 设置 Prometheus 导出器,但是我遇到了困难。

我有一个使用 docker 容器构建的基于 Web 的应用程序,我现在通过使用 keycloak 添加用户权限

我在 github 上找到了这个 https://github.com/aerogear/keycloak-metrics-spi但是我从来没有真正将这样的东西与 Docker 结合使用,所以我不确定我是否正确执行了自述文件中的步骤

请注意,我手动执行了以下所有步骤。

  1. 下载并解压github repo到主机
  2. 运行命令“./gradlew jar”
  3. 在名为 providers 的 keycloak 目录中创建了一个新目录
  4. 将 jar 文件从/build/libs 复制到提供者 foler
  5. 转到 Keycloak GUI 并转到 mange -> events -> config 并添加 metrics-listener 作为命名条目

在此之后,基于 github 存储库,我去了 localhost/auth/realms/master/metrics,但是那里什么也没有。我是否正确设置了它?或者,有人知道可能更适合使用 docker 设置的任何其他导出商吗?

谢谢

最佳答案

文件需要进入以下文件夹:

/opt/jboss/keycloak/standalone/deployments

这是我的 InSpec 测试套件,用于验证提供程序部署:

control 'keycloak-metrics-1' do
impact 0.6
title 'Metrics endpoint activation script'
desc 'The script should exist and be executable'
tag 'keycloak','prometheus','monitoring'
ref 'KeyCloak Metrics SPI README', url: 'https://github.com/aerogear/keycloak-metrics-spi'

describe file('/opt/jboss/startup-scripts/enable-prometheus-exporter.sh') do
it { should be_file }
it { should be_executable }
end
end

control 'keycloak-metrics-2' do
impact 1.0
title 'Metrics provider artifact'
desc 'The provider jar should exist and be deployed successfully'
tag 'keycloak','prometheus','monitoring'
ref 'KeyCloak Metrics SPI README', url: 'https://github.com/aerogear/keycloak-metrics-spi'

# e.g. keycloak-metrics-spi-1.0.1-SNAPSHOT.jar
describe command('ls /opt/jboss/keycloak/standalone/deployments/*.jar').stdout.chomp do
it { should match /keycloak-metrics-spi/ }
end

# e.g. keycloak-metrics-spi-1.0.1-SNAPSHOT.jar.deployed
describe command('ls /opt/jboss/keycloak/standalone/deployments/*.deployed').stdout.chomp do
it { should match /keycloak-metrics-spi/ }
end
end

control 'keycloak-metrics-3' do
impact 0.6
title 'Metrics endpoint'
desc 'The metrics endpoint returns expected data'
tag 'keycloak','prometheus','monitoring'
ref 'KeyCloak Metrics SPI README', url: 'https://github.com/aerogear/keycloak-metrics-spi'

describe http('http://localhost:8080/auth/realms/master/metrics') do
its('status') { should cmp 200 }
its('body') { should match /keycloak_user_event/ }
end
end

关于keycloak - 设置 Keycloak 导出器以与 Prometheus 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54606256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com