or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

auto-configuration.mdconfiguration-properties.mddatasource-management.mdfilter-configuration.mdindex.mdmonitoring-integration.md

configuration-properties.mddocs/

0

# Configuration Properties

1

2

The Druid Spring Boot Starter provides comprehensive type-safe configuration properties for all Druid settings including connection pool parameters, monitoring options, and filter configurations.

3

4

## Capabilities

5

6

### DruidStatProperties

7

8

Main configuration properties class that provides type-safe binding for Druid monitoring and statistics configuration.

9

10

```java { .api }

11

/**

12

* Main configuration properties for Druid monitoring and statistics

13

* Bound to spring.datasource.druid configuration prefix

14

*/

15

@ConfigurationProperties("spring.datasource.druid")

16

public class DruidStatProperties {

17

18

/**

19

* AOP patterns for Spring method monitoring

20

* @return Array of patterns for AOP pointcut matching

21

*/

22

String[] getAopPatterns();

23

24

/**

25

* Sets AOP patterns for Spring method monitoring

26

* @param aopPatterns Array of patterns (e.g., "com.example.service.*", "com.example.dao.*")

27

*/

28

void setAopPatterns(String[] aopPatterns);

29

30

/**

31

* Gets StatViewServlet configuration

32

* @return StatViewServlet configuration object

33

*/

34

StatViewServlet getStatViewServlet();

35

36

/**

37

* Sets StatViewServlet configuration

38

* @param statViewServlet Configuration for web monitoring console

39

*/

40

void setStatViewServlet(StatViewServlet statViewServlet);

41

42

/**

43

* Gets WebStatFilter configuration

44

* @return WebStatFilter configuration object

45

*/

46

WebStatFilter getWebStatFilter();

47

48

/**

49

* Sets WebStatFilter configuration

50

* @param webStatFilter Configuration for web statistics filter

51

*/

52

void setWebStatFilter(WebStatFilter webStatFilter);

53

}

54

```

55

56

### StatViewServlet Configuration

57

58

Nested configuration class for the Druid monitoring web console.

59

60

```java { .api }

61

/**

62

* Configuration for Druid's web-based monitoring console

63

* Bound to spring.datasource.druid.stat-view-servlet configuration prefix

64

*/

65

public static class StatViewServlet {

66

67

/**

68

* Whether StatViewServlet is enabled

69

* @return true if monitoring console is enabled, false by default for security

70

*/

71

boolean isEnabled();

72

73

/**

74

* Enables or disables the StatViewServlet

75

* @param enabled true to enable monitoring console (requires security configuration)

76

*/

77

void setEnabled(boolean enabled);

78

79

/**

80

* URL pattern for the monitoring servlet

81

* @return URL pattern (default: "/druid/*")

82

*/

83

String getUrlPattern();

84

85

/**

86

* Sets URL pattern for monitoring servlet access

87

* @param urlPattern URL pattern (e.g., "/druid/*", "/monitor/*")

88

*/

89

void setUrlPattern(String urlPattern);

90

91

/**

92

* IP whitelist for monitoring console access

93

* @return Comma-separated list of allowed IP addresses

94

*/

95

String getAllow();

96

97

/**

98

* Sets IP whitelist for security

99

* @param allow Comma-separated IPs (e.g., "127.0.0.1,192.168.1.100")

100

*/

101

void setAllow(String allow);

102

103

/**

104

* IP blacklist for monitoring console access

105

* @return Comma-separated list of denied IP addresses

106

*/

107

String getDeny();

108

109

/**

110

* Sets IP blacklist for security

111

* @param deny Comma-separated IPs to block

112

*/

113

void setDeny(String deny);

114

115

/**

116

* Login username for monitoring console

117

* @return Username for console authentication

118

*/

119

String getLoginUsername();

120

121

/**

122

* Sets login username for console access

123

* @param loginUsername Username for authentication

124

*/

125

void setLoginUsername(String loginUsername);

126

127

/**

128

* Login password for monitoring console

129

* @return Password for console authentication

130

*/

131

String getLoginPassword();

132

133

/**

134

* Sets login password for console access

135

* @param loginPassword Password for authentication

136

*/

137

void setLoginPassword(String loginPassword);

138

139

/**

140

* Whether reset functionality is enabled in console

141

* @return "true" or "false" string value

142

*/

143

String getResetEnable();

144

145

/**

146

* Enables or disables reset functionality

147

* @param resetEnable "true" to enable reset, "false" to disable

148

*/

149

void setResetEnable(String resetEnable);

150

}

151

```

152

153

### WebStatFilter Configuration

154

155

Nested configuration class for web request statistics collection.

156

157

```java { .api }

158

/**

159

* Configuration for Druid's web statistics filter

160

* Bound to spring.datasource.druid.web-stat-filter configuration prefix

161

*/

162

public static class WebStatFilter {

163

164

/**

165

* Whether WebStatFilter is enabled

166

* @return true if web statistics collection is enabled, false by default

167

*/

168

boolean isEnabled();

169

170

/**

171

* Enables or disables web statistics collection

172

* @param enabled true to enable web request monitoring

173

*/

174

void setEnabled(boolean enabled);

175

176

/**

177

* URL pattern for filter application

178

* @return URL pattern (default: "/*")

179

*/

180

String getUrlPattern();

181

182

/**

183

* Sets URL pattern for web statistics collection

184

* @param urlPattern Pattern for URLs to monitor (e.g., "/*", "/api/*")

185

*/

186

void setUrlPattern(String urlPattern);

187

188

/**

189

* URL exclusions from statistics collection

190

* @return Comma-separated list of excluded URL patterns

191

*/

192

String getExclusions();

193

194

/**

195

* Sets URL exclusions to skip monitoring

196

* @param exclusions Patterns to exclude (e.g., "*.js,*.css,*.ico,/druid/*")

197

*/

198

void setExclusions(String exclusions);

199

200

/**

201

* Maximum number of session statistics to track

202

* @return String representation of maximum count

203

*/

204

String getSessionStatMaxCount();

205

206

/**

207

* Sets maximum session statistics count

208

* @param sessionStatMaxCount Maximum number of sessions to track

209

*/

210

void setSessionStatMaxCount(String sessionStatMaxCount);

211

212

/**

213

* Whether session statistics are enabled

214

* @return "true" or "false" string value

215

*/

216

String getSessionStatEnable();

217

218

/**

219

* Enables or disables session statistics

220

* @param sessionStatEnable "true" to enable session monitoring

221

*/

222

void setSessionStatEnable(String sessionStatEnable);

223

224

/**

225

* Principal session name for user tracking

226

* @return Session attribute name for principal identification

227

*/

228

String getPrincipalSessionName();

229

230

/**

231

* Sets principal session name for user identification

232

* @param principalSessionName Session attribute name (e.g., "user", "principal")

233

*/

234

void setPrincipalSessionName(String principalSessionName);

235

236

/**

237

* Principal cookie name for user tracking

238

* @return Cookie name for principal identification

239

*/

240

String getPrincipalCookieName();

241

242

/**

243

* Sets principal cookie name for user identification

244

* @param principalCookieName Cookie name for user tracking

245

*/

246

void setPrincipalCookieName(String principalCookieName);

247

248

/**

249

* Whether request profiling is enabled

250

* @return "true" or "false" string value

251

*/

252

String getProfileEnable();

253

254

/**

255

* Enables or disables request profiling

256

* @param profileEnable "true" to enable detailed request profiling

257

*/

258

void setProfileEnable(String profileEnable);

259

}

260

```

261

262

## Configuration Examples

263

264

### Basic Monitoring Configuration

265

266

```properties

267

# Enable StatViewServlet (monitoring console)

268

spring.datasource.druid.stat-view-servlet.enabled=true

269

spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*

270

spring.datasource.druid.stat-view-servlet.login-username=admin

271

spring.datasource.druid.stat-view-servlet.login-password=admin123

272

spring.datasource.druid.stat-view-servlet.allow=127.0.0.1,192.168.1.100

273

spring.datasource.druid.stat-view-servlet.reset-enable=false

274

275

# Enable WebStatFilter (web request monitoring)

276

spring.datasource.druid.web-stat-filter.enabled=true

277

spring.datasource.druid.web-stat-filter.url-pattern=/*

278

spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*

279

spring.datasource.druid.web-stat-filter.session-stat-enable=true

280

spring.datasource.druid.web-stat-filter.session-stat-max-count=1000

281

```

282

283

### AOP Monitoring Configuration

284

285

```properties

286

# Enable AOP method monitoring

287

spring.datasource.druid.aop-patterns=com.example.service.*,com.example.dao.*,com.example.controller.*

288

```

289

290

### YAML Configuration Example

291

292

```yaml

293

spring:

294

datasource:

295

druid:

296

# StatViewServlet configuration

297

stat-view-servlet:

298

enabled: true

299

url-pattern: /druid/*

300

login-username: admin

301

login-password: secure123

302

allow: 127.0.0.1,10.0.0.0/8

303

deny: 192.168.0.100

304

reset-enable: false

305

306

# WebStatFilter configuration

307

web-stat-filter:

308

enabled: true

309

url-pattern: /*

310

exclusions: "*.js,*.css,*.ico,/druid/*,/static/*"

311

session-stat-enable: true

312

session-stat-max-count: 2000

313

principal-session-name: user

314

profile-enable: true

315

316

# AOP monitoring patterns

317

aop-patterns:

318

- com.example.service.*

319

- com.example.dao.*

320

- com.example.controller.*

321

```

322

323

## Property Binding Integration

324

325

The configuration properties integrate with Spring Boot's configuration property binding system:

326

327

### Type Safety

328

329

All properties are strongly typed, providing compile-time checking and IDE autocomplete support.

330

331

### Validation

332

333

Spring Boot automatically validates property values and provides meaningful error messages for invalid configurations.

334

335

### Environment Integration

336

337

Properties can be set via:

338

- `application.properties` or `application.yml` files

339

- Environment variables (e.g., `SPRING_DATASOURCE_DRUID_STAT_VIEW_SERVLET_ENABLED=true`)

340

- Command line arguments (e.g., `--spring.datasource.druid.stat-view-servlet.enabled=true`)

341

- External configuration sources

342

343

### Profile Support

344

345

Configuration can be profile-specific:

346

347

```yaml

348

spring:

349

profiles: development

350

datasource:

351

druid:

352

stat-view-servlet:

353

enabled: true

354

login-username: dev

355

login-password: dev123

356

357

---

358

spring:

359

profiles: production

360

datasource:

361

druid:

362

stat-view-servlet:

363

enabled: true

364

login-username: admin

365

login-password: ${DRUID_ADMIN_PASSWORD}

366

allow: 10.0.0.0/8

367

```

368

369

## Security Considerations

370

371

### StatViewServlet Security

372

373

- **Disabled by Default**: StatViewServlet is disabled by default for security

374

- **Authentication**: Always set login username/password in production

375

- **IP Filtering**: Use `allow` and `deny` properties to restrict access

376

- **Reset Protection**: Disable reset functionality in production environments

377

378

### WebStatFilter Privacy

379

380

- **URL Exclusions**: Exclude sensitive endpoints from monitoring

381

- **Session Tracking**: Be mindful of privacy when enabling session statistics

382

- **Data Retention**: Configure appropriate limits for statistics storage