【Grafana】Grafana匿名访问以及与LDAP连接

上一篇文章利用Docker快速部署了Grafana用来展示Zabbix得监控数据,但还需要给用户去创建账号允许他们登录后才能看展示得数据,那有什么办法让非管理员更方便得去访问Grafana呢?下面介绍两个比较方便实现的:
在开始设置前,为了数据持久化,需要对上一篇中的Docker启动中加入配置文件的持久化配置,具体如下:

# create a persistent volume for data
docker volume create grafana-data

# create a persistent volume for log
docker volume create grafana-log

# create a persistent volume for config
docker volume create grafana-config

# start grafana by using the above persistent storage and defining environment variables
docker run -d -p 3000:3000 --name=grafana --volume grafana-storage:/var/lib/grafana --volume grafana-log:/var/log/grafana --volume grafana-config:/etc/grafana -e "GF_INSTALL_PLUGINS=alexanderzobnin-zabbix-app" grafana/grafana-oss:latest

然后通过以下找到配置文件的具体位置

docker volume inspect grafana-config
[
    {
        "CreatedAt": "2023-12-22T03:25:15Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/grafana-config/_data",
        "Name": "grafana-config",
        "Options": null,
        "Scope": "local"
    }
]
cd /var/lib/docker/volumes/grafana-config/_data

文件夹内的grafana.ini, ldap.toml是下面配置的重点。

  1. 匿名访问
    通过在配置文件中启用匿名访问来使 Grafana 可以在无需登录的情况下访问。在grafana.ini中找到以下部分并修改
#################################### Anonymous Auth ######################
[auth.anonymous]
# enable anonymous access (default: false)
enabled = true

# Organization name that should be used for unauthenticated users (default: Main Org.)
org_name = Main Org.

# Role for unauthenticated users, other valid values are `Editor` and `Admin` (default: Viewer)
org_role = Viewer

# Hide the Grafana version text from the footer and help tooltip for unauthenticated users (default: false)
hide_version = true

保存配置文件后,重启docker。

docker restart grafana

在浏览器中直接访问http://IP:3000/,即可以得到以下显示了。普通用户就不用登录即可查看dashboard了。
在这里插入图片描述

  1. 与LDAP(Windows AD)连接,统一认证登录
    要使用 LDAP 集成,首先需要在主配置文件中启用 LDAP,并指定 LDAP 特定配置文件的路径(默认为 /etc/grafana/ldap.toml)。
    启用 LDAP 后,默认行为是在成功进行 LDAP 身份验证后自动创建 Grafana 用户。如果希望只允许现有的 Grafana 用户登录,您可以在 [auth.ldap]部分将 allow_sign_up 更改为 false。如果希望手动分配组织和角色,可以使用 skip_org_role_sync 配置选项。
#################################### Auth LDAP ##########################
[auth.ldap]
# Set to `true` to enable LDAP integration (default: `false`)
enabled = true

# Path to the LDAP specific configuration file (default: `/etc/grafana/ldap.toml`)
config_file = /etc/grafana/ldap.toml

# Allow sign-up should be `true` (default) to allow Grafana to create users on successful LDAP authentication.
# If set to `false` only already existing Grafana users will be able to login. (default: `true`)
allow_sign_up = true

# Prevent synchronizing ldap users organization roles (default: `false`)
skip_org_role_sync = false

修改完grafana.ini后然后修改ldap.toml文件,需要注意的是如下配置适用于Windows AD提供的LDAP设置。

# To troubleshoot and get more log info enable ldap debug logging in grafana.ini
# [log]
# filters = ldap:debug

[[servers]]
# Ldap server host (specify multiple hosts space separated)
host = "ldap.my_secure_remote_server.org"
# Default port is 389 or 636 if use_ssl = true
port = 389
# Set to true if LDAP server should use an encrypted TLS connection (either with STARTTLS or LDAPS)
use_ssl = false
# If set to true, use LDAP with STARTTLS instead of LDAPS
start_tls = false
# The value of an accepted TLS cipher. By default, this value is empty. Example value: ["TLS_AES_256_GCM_SHA384"])
# For a complete list of supported ciphers and TLS versions, refer to: https://go.dev/src/crypto/tls/cipher_suites.go
tls_ciphers = []
# This is the minimum TLS version allowed. By default, this value is empty. Accepted values are: TLS1.1, TLS1.2, TLS1.3.
min_tls_version = ""
# set to true if you want to skip ssl cert validation
ssl_skip_verify = false
# set to the path to your root CA certificate or leave unset to use system defaults
# root_ca_cert = "/path/to/certificate.crt"
# Authentication against LDAP servers requiring client certificates
# client_cert = "/path/to/client.crt"
# client_key = "/path/to/client.key"

# Search user bind dn
bind_dn = "cn=admin,dc=grafana,dc=org"
# Search user bind password
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
bind_password = "grafana"
# We recommend using variable expansion for the bind_password, for more info https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#variable-expansion
# bind_password = '$__env{LDAP_BIND_PASSWORD}'

# Timeout in seconds (applies to each host specified in the 'host' entry (space separated))
timeout = 10

# User search filter, for example "(cn=%s)" or "(sAMAccountName=%s)" or "(uid=%s)"
search_filter = "(sAMAccountName=%s)"

# An array of base dns to search through
search_base_dns = ["dc=grafana,dc=org"]

## For Posix or LDAP setups that does not support member_of attribute you can define the below settings
## Please check grafana LDAP docs for examples
# group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))"
# group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]
# group_search_filter_user_attribute = "uid"

# Specify names of the ldap attributes your ldap uses
[servers.attributes]
name = "givenName"
surname = "sn"
username = "sAMAccountName"
member_of = "memberOf"
email =  "email"

# Map ldap groups to grafana org roles
[[servers.group_mappings]]
group_dn = "cn=admins,ou=groups,dc=grafana,dc=org"
org_role = "Admin"
# To make user an instance admin  (Grafana Admin) uncomment line below
# grafana_admin = true
# The Grafana organization database id, optional, if left out the default org (id 1) will be used
# org_id = 1

[[servers.group_mappings]]
group_dn = "cn=editors,ou=groups,dc=grafana,dc=org"
org_role = "Editor"

[[servers.group_mappings]]
# If you want to match all (or no ldap groups) then you can use wildcard
group_dn = "*"
org_role = "Viewer"

更多配置可以参考Grafana官方说明。保存配置文件后,重启docker。

docker restart grafana

用AD账号登录后可以看到个人资料里面,很多信息就是从AD同步过来的。
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/264450.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

FastAPI实现文件上传下载

FastAPI实现文件上传下载 1.后端FastAPI2.后端html3.效果 最近的项目需求,是前端vue,后端fastAPI,然后涉及到图像的消息发送,所以需要用fast写文件上传下载的接口,这里简单记录一下。 1.后端FastAPI import os.path i…

C++的面向对象学习(5):对象的重要特性:对象的成员变量和成员函数深入研究

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 一、static修饰的静态成员:与类本身关联,不依赖于任何对象。①静态成员变量:②静态成员函数:(1&#xff…

Docker 编译OpenHarmony 4.0 release

一、背景介绍 1.1、环境配置 编译环境:Ubuntu 20.04OpenHarmony版本:4.0 release平台设备:RK3568 OpenHarmony 3.2更新至OpenHarmony 4.0后,公司服务器无法编译通过,总是在最后几十个文件时报错,错误码4000&#xf…

python+django教学质量评价系统o8x1z

本基于web的在线教学质量评价系统的设计与实现有管理员,教师,督导,学生一共四个角色。管理员功能有个人中心,学生管理,教师管理,督导管理,学生评价管理,课程信息管理,学生…

less 查看文本时,提示may be a binary file.See it anyway?

解决办法 首先使用echo $LESSCHARSET查看less的编码 看情况设置less的编码格式(我的服务器上使用utf-8查看中文) 还要特别注意一下,Linux中存在的文本文件的编码一定要是utf - 8;(这一步很关键) 例如:要保证windows上传到Linux的…

Centos系统升级gcc版本

自己环境的gcc版本太低,影响使用SAN全家桶进行内存泄露检查 当前环境gcc版本查看 gcc --version 进行升级: 1、安装EPEL存储库 yum install epel-release -y 2、确保系统已经更新到最新版本 yum update -y 3、安装GCC编译器及其相关工具包 yum g…

The Cherno C++笔记 03

目录 Part 07 How the C Linker Works 1.链接 2.编译链接过程中出现的错误 2.1 缺少入口函数 注意:如何区分编译错误还是链接错误 注意:入口点可以自己设置 2.2 找不到自定义函数 2.2.1缺少声明 2.2.2自定义函数与引用函数不一致 2.3 在头文件中放入定义 …

基于kubernetes实现PaaS云平台-rancher

基于Rancher实现kubernetes集群管理 一、Rancher介绍 1.1 Rancher Rancher 是一套容器管理平台,它可以帮助组织在生产环境中轻松快捷的部署和管理容器。Rancher可以轻松地管理各种环境的 Kubernetes,满足IT需求并为 DevOps 团队提供支持。 Rancher 用…

css 设备背景图片 宽高总是不能平铺

宽高总是宽大了 高就挤出去了;高设置了 宽度就变小了;疯掉的节奏。。。。。。 .center-bottom{background: url(/img/newpic/leftbg.png);background-repeat: no-repeat;width: 98%;height: 60%;background-position: center center;background-size: 1…

STM32微控制器在HC-SR501红外感应模块中的能耗优化策略研究

一、 引言 能耗优化是嵌入式系统设计中一个重要的考虑因素,特别是在电池供电的应用中。在使用HC-SR501红外感应模块时,能耗优化策略对于延长电池寿命、提高系统性能至关重要。本文将阐述基于STM32微控制器的HC-SR501红外感应模块能耗优化策略研究。 二、…

Apache Flink 进阶教程(六):Flink 作业执行深度解析

目录 前言 Flink 四层转化流程 Program 到 StreamGraph 的转化 StreamGraph 到 JobGraph 的转化 为什么要为每个 operator 生成 hash 值? 每个 operator 是怎样生成 hash 值的? JobGraph 到 ExexcutionGraph 以及物理执行计划 Flink Job 执行流程…

web架构师编辑器内容-改进字体下拉菜单

前面说到我们可以通过面板配置来更新画布上面的一些属性,如果我们有这样一个需求:在右侧面板配置里面需要查看字体的样式效果我们应该怎么做呢? 我们一开始字体的渲染: const fontFamilyArr [{value: "SimSun","…

parseInt(0.0000005)大于等于5

文章目录 一、前言二、parseInt()的神秘行为三、解决parseInt()的奥秘四、结论五、最后 一、前言 parseInt() 是 JavaScript 的内置函数,用于解析数字字符串中的整数。例如,从数字字符串中解析整数100: const number parseInt(100); numbe…

nodejs+vue+微信小程序+python+PHP医疗机构药品及耗材信息管理系统-计算机毕业设计推荐

为了帮助用户更好的了解和理解程序的开发流程与相关内容,本文将通过六个章节进行内容阐述。 第一章:描述了程序的开发背景,程序运用于现实生活的目的与意义,以及程序文档的结构安排信息; 第二章:描述了程序…

第11章 GUI Page400~402 步骤二 画直线

运行效果: 源代码: /**************************************************************** Name: wxMyPainterApp.h* Purpose: Defines Application Class* Author: yanzhenxi (3065598272qq.com)* Created: 2023-12-21* Copyright: yanzhen…

vue3开发一个todo List

创建新的 Vue 3 项目: 按装vue3的 工具 npm install -g vue/cli创建一个新的 Vue 3 项目: vue create vue3-todolist进入项目目录: cd vue3-todolist代码: 在项目的 src/components 目录下,创建一个新的文件 Todo…

视频美颜SDK开发指南:实现高质量实时美颜效果

下文小编将于大家一同探讨美颜SDK的开发指南,希望开发者们能够获得一定的启发。 一、理解实时美颜的挑战 实时美颜涉及到对视频流进行实时处理,这对计算资源和算法效率提出了严峻的挑战。在开发视频美颜SDK之前,我们需要理解以下几个关键方…

【Amazon 实验②】Amazon WAF功能增强之使用Cloudfront、Lambda@Edge阻挡攻击

文章目录 一、方案介绍二、架构图三、部署方案1. 进入Cloud9 编辑器,新打开一个teminal2. 克隆代码3. 解绑上一个实验中Cloudfront 分配绑定的防火墙4. 使用CDK部署方案5. CDK部署完成6. 关联LambdaEdge函数 四、方案效果 一、方案介绍 采用 LambdaEdge DynamoDB 架…

Web组态可视化编辑器-by组态

演示地址: http://www.by-lot.com http://www.byzt.net web组态可视化编辑器:引领未来可视化编辑的新潮流 随着网络的普及和快速发展,web组态可视化编辑器应运而生,为人们在网络世界中创建和编辑内容提供了更加便捷的操作方式。这…

【ARMv8M Cortex-M33 系列 1 -- SAU 介绍】

文章目录 Cortex-M33 SAU 介绍SAU 的主要功能包括SAU 寄存器配置示例 Cortex-M33 SAU 介绍 在 ARMv8-M 架构中,SAU(Security Attribution Unit)是安全属性单元,用于配置和管理内存区域的安全属性。SAU 是 ARM TrustZone 技术的一…
最新文章