Skip to content

Commit 60b73c9

Browse files
authored
feat: introduct flag to disable service URL globally or per instance (#4619)
1 parent 9c13b85 commit 60b73c9

File tree

18 files changed

+376
-128
lines changed

18 files changed

+376
-128
lines changed

spring-boot-admin-docs/src/site/docs/client/02-configuration.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ sidebar_custom_props:
55

66
# Configuration
77

8-
In addition to discovering and registering services, Spring Boot Admin makes use of metadata to control how individual clients are handled by the server.
9-
Metadata allows you to fine-tune the behavior of the admin server for each registered service and can influence how services are displayed, monitored, or interacted with.
8+
In addition to discovering and registering services, Spring Boot Admin makes use of metadata to control how individual
9+
clients are handled by the server.
10+
Metadata allows you to fine-tune the behavior of the admin server for each registered service and can influence how
11+
services are displayed, monitored, or interacted with.
1012
A set of well-defined metadata attributes is recognized and evaluated directly on the server side.
11-
Because the Spring Boot Admin client itself relies on the same Spring Cloud interfaces, these metadata properties can also be applied consistently on the client, ensuring
13+
Because the Spring Boot Admin client itself relies on the same Spring Cloud interfaces, these metadata properties can
14+
also be applied consistently on the client, ensuring
1215
a unified configuration approach across your entire system.
1316

1417
__Instance metadata options__
@@ -17,6 +20,7 @@ __Instance metadata options__
1720
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
1821
| `tags.*` | Tags as key-value-pairs to be associated with this instance. |
1922
| `group` | Assign a group name. Used in UI to aggregate instances not by application but by assigned group. |
20-
| `hide-url` | Hide URLs of the instance in UI. |
23+
| `hide-url` | Hide URLs of the instance in UI. Useful, when running in a cluster, exposing a non routable URL. |
24+
| `disable-url` | Disables links of this instance in UI. Useful, when the URL does not point to a UI. |
2125
| `service-url` | Override the service url of the registered service. Allows to specify the actual URL to the UI. This does not affect management url. |
2226
| `user.name`<br/>`user.password` | Credentials being used to access the endpoints. |

spring-boot-admin-docs/src/site/docs/customize/01-customize_ui.md

Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
sidebar_custom_props:
3+
icon: 'ui'
4+
---
5+
6+
import metadata
7+
from "../../../../../spring-boot-admin-server-ui/target/classes/META-INF/spring-configuration-metadata.json";
8+
import { PropertyTable } from "../../src/components/PropertyTable";
9+
10+
# Look and Feel
11+
12+
You can set custom information in the header (i.e. displaying staging information or company name) by using following
13+
configuration properties:
14+
15+
* **spring.boot.admin.ui.brand**: This HTML snippet is rendered in navigation header and defaults to
16+
`<img src="assets/img/icon-spring-boot-admin.svg"><span>Spring Boot Admin</span>`. By default, it shows the SBA logo
17+
followed by its name. If you want to show a custom logo you can set:
18+
`spring.boot.admin.ui.brand=<img src="custom/custom-icon.png">`. Either you just add the image to your jar-file in
19+
`/META-INF/spring-boot-admin-server-ui/` (SBA registers a `ResourceHandler` for this location by default), or you must
20+
ensure yourself that the image gets served correctly (e.g. by registering your own `ResourceHandler`)
21+
* **spring.boot.admin.ui.title**: Use this option to customize the browsers window title.
22+
23+
## Customizing Colors
24+
25+
You can provide a custom color theme to the application by overwriting the following properties:
26+
27+
```yaml title="application.yml"
28+
spring:
29+
boot:
30+
admin:
31+
ui:
32+
theme:
33+
color: "#4A1420"
34+
palette:
35+
50: "#F8EBE4"
36+
100: "#F2D7CC"
37+
200: "#E5AC9C"
38+
300: "#D87B6C"
39+
400: "#CB463B"
40+
500: "#9F2A2A"
41+
600: "#83232A"
42+
700: "#661B26"
43+
800: "#4A1420"
44+
900: "#2E0C16"
45+
```
46+
47+
<PropertyTable
48+
properties={metadata.properties}
49+
filter={[
50+
'spring.boot.admin.ui.theme.color',
51+
'spring.boot.admin.ui.theme.background-enabled',
52+
'spring.boot.admin.ui.theme.palette',
53+
]}
54+
exclusive={false}
55+
additionalProperties={[
56+
{
57+
name: 'spring.boot.admin.ui.theme.palette.*',
58+
description: 'Define a color palette that affects the colors in sidebar view (e.g shade 600 of palette is used as text color and shade 50 as background color.)',
59+
defaultValue: '50: #E8FBEF 100: #D0F7DF 200: #A1EFBD 300: #71E69C 400: #41DE7B 500: #22C55E 600: #1A9547 700: #116530 800: #09351A 900: #010603'
60+
}
61+
]}
62+
/>
63+
64+
## Customizing Login Logo
65+
66+
You can set a custom image to be displayed on the login page.
67+
68+
1. Put the image in a resource location which is served via http (e.g.
69+
`/META-INF/spring-boot-admin-server-ui/assets/img/`).
70+
2. Configure the icons to use using the following property:
71+
* **spring.boot.admin.ui.login-icon**: Used as icon on login page. (e.g `assets/img/custom-login-icon.svg`)
72+
73+
## Customizing Favicon
74+
75+
It is possible to use a custom favicon, which is also used for desktop notifications. Spring Boot Admin uses a different
76+
icon when one or more application is down.
77+
78+
1. Put the favicon (`.png` with at least 192x192 pixels) in a resource location which is served via http (e.g.
79+
`/META-INF/spring-boot-admin-server-ui/assets/img/`).
80+
2. Configure the icons to use using the following properties:
81+
* `spring.boot.admin.ui.favicon`: Used as default icon. (e.g `assets/img/custom-favicon.png`
82+
* `spring.boot.admin.ui.favicon-danger`: Used when one or more service is down. (e.g
83+
`assets/img/custom-favicon-danger.png`)
84+
85+
## Customizing Available Languages
86+
87+
To filter languages to a subset of all supported languages:
88+
89+
* **spring.boot.admin.ui.available-languages**: Used as a filter of existing languages. (e.g. `en,de` out of existing
90+
`de,en,fr,ko,pt-BR,ru,zh`)
91+
92+
## Show or hide views
93+
94+
You can very simply hide views in the navbar:
95+
96+
```yaml title="application.yml"
97+
spring:
98+
boot:
99+
admin:
100+
ui:
101+
view-settings:
102+
- name: "journal"
103+
enabled: false
104+
```
105+
106+
## Hide Service URL
107+
108+
To hide service URLs in Spring Boot Admin UI entirely, set the following property in your Server's configuration:
109+
110+
<PropertyTable
111+
properties={metadata.properties}
112+
filter={[
113+
'spring.boot.admin.ui.hide-instance-url',
114+
'spring.boot.admin.ui.disable-instance-url',
115+
'spring.boot.admin.ui.theme.palette',
116+
]}
117+
exclusive={false}
118+
/>
119+
120+
If you want to hide the URL for specific instances only, you can set the `hide-url` property in the instance metadata
121+
while registering a service.
122+
When using Spring Boot Admin Client you can set the property `spring.boot.admin.client.metadata.hide-url=true` in the
123+
corresponding config file. The value set in `metadata` does not have any effect, when the URLs are disabled in Server.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
sidebar_custom_props:
3+
icon: 'properties'
4+
---
5+
# Properties
6+
7+
import metadata from "../../../../../spring-boot-admin-server-ui/target/classes/META-INF/spring-configuration-metadata.json";
8+
import { PropertyTable } from "../../src/components/PropertyTable";
9+
10+
<PropertyTable
11+
properties={metadata.properties}
12+
/>

spring-boot-admin-docs/src/site/src/components/PropertyTable.tsx

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
import { filterPropertiesByName } from "@site/src/propertiesUtil";
2-
import styles from "./PropertyTable.module.css"
2+
import styles from "./PropertyTable.module.css";
33
import { CopyButton } from "@site/src/components/CopyButton";
44

55
type Props = {
66
title?: string;
7-
properties: Array<Record<string, any>>
7+
properties: Array<SpringPropertyDefinition>
88
filter?: Array<string>
9-
exclusive?: boolean
9+
exclusive?: boolean,
10+
additionalProperties: Array<SpringPropertyDefinition>
1011
}
1112

12-
export function PropertyTable({title, properties, filter = [], exclusive = true}: Props) {
13+
export function PropertyTable({
14+
title,
15+
properties,
16+
filter = [],
17+
exclusive = true,
18+
additionalProperties = [] as Array<SpringPropertyDefinition>,
19+
}: Readonly<Props>) {
1320
const filteredProperties = filterPropertiesByName(properties, filter, exclusive)
14-
.sort((a,b) => {
21+
.sort((a, b) => {
1522
return a.name.length - b.name.length || a.name.localeCompare(b.name);
1623
});
1724

25+
const propertiesToShow = [
26+
...filteredProperties,
27+
...additionalProperties
28+
];
29+
30+
const hasDefaultValueOrType = (property: SpringPropertyDefinition) => {
31+
console.log(property.defaultValue, typeof property.defaultValue);
32+
console.log(property.type, typeof property.type);
33+
return property.defaultValue || property.type
34+
}
35+
1836
return (
1937
<table className={styles.propertyTable}>
2038
{title && <caption>{title}</caption>}
@@ -25,7 +43,7 @@ export function PropertyTable({title, properties, filter = [], exclusive = true}
2543
</tr>
2644
</thead>
2745
<tbody>
28-
{filteredProperties.map((a) => (
46+
{propertiesToShow.map((a) => (
2947
<>
3048
<tr key={a.name}>
3149
<td className={styles.propertyCell}>
@@ -37,19 +55,21 @@ export function PropertyTable({title, properties, filter = [], exclusive = true}
3755
</div>
3856
</td>
3957
<td>
40-
<p>
41-
{a.description}
42-
</p>
43-
{a.defaultValue && (
44-
<dl className='dl-horizontal'>
45-
<div>
46-
<dt><span style={{ fontStyle: "italic" }}>Type:</span>&nbsp;</dt>
47-
<dd><code>{a.type}</code></dd>
48-
</div>
49-
<div>
50-
<dt><span style={{ fontStyle: "italic" }}>Default:</span>&nbsp;</dt>
51-
<dd><code>{JSON.stringify(a.defaultValue)}</code></dd>
52-
</div>
58+
<p dangerouslySetInnerHTML={{__html: a.description}} />
59+
{hasDefaultValueOrType(a) && (
60+
<dl>
61+
{a.type && (
62+
<div>
63+
<dt><span style={{ fontStyle: "italic" }}>Type:</span>&nbsp;</dt>
64+
<dd><code>{a.type}</code></dd>
65+
</div>
66+
)}
67+
{a.defaultValue && (
68+
<div>
69+
<dt><span style={{ fontStyle: "italic" }}>Default:</span>&nbsp;</dt>
70+
<dd><code>{JSON.stringify(a.defaultValue)}</code></dd>
71+
</div>
72+
)}
5373
</dl>
5474
)}
5575
</td>

spring-boot-admin-docs/src/site/src/css/custom.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,18 @@
2121
main[class^='docMainContainer'] {
2222
position: relative;
2323
}
24+
25+
.dl-horizontal {
26+
* {
27+
margin: 0;
28+
}
29+
div {
30+
display: grid;
31+
gap: .5rem;
32+
grid-template-columns: repeat(3, 1fr);
33+
34+
dd {
35+
grid-column: span 2 / span 2;
36+
}
37+
}
38+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export {};
2+
3+
declare global {
4+
type SpringPropertyDefinition = {
5+
name: string;
6+
description: string;
7+
type?: string;
8+
defaultValue?: string;
9+
}
10+
}

spring-boot-admin-docs/src/site/src/propertiesUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const filterPropertiesByName = (
2-
properties: Array<Record<string, string>>,
2+
properties: Array<SpringPropertyDefinition>,
33
keywords: string[],
44
exclusive: boolean = true
55
) => {

spring-boot-admin-server-ui/src/main/frontend/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ declare global {
7373
viewSettings: ViewSettings[];
7474
enableToasts: boolean;
7575
hideInstanceUrl: boolean;
76+
disableInstanceUrl: boolean;
7677
};
7778

7879
type SBASettings = {

0 commit comments

Comments
 (0)