1717package org .springframework .boot .actuate .autoconfigure .metrics .export .prometheus ;
1818
1919import java .time .Duration ;
20+ import java .util .HashMap ;
21+ import java .util .Map ;
2022
23+ import org .springframework .boot .actuate .metrics .export .prometheus .PrometheusPushGatewayManager .ShutdownOperation ;
2124import org .springframework .boot .context .properties .ConfigurationProperties ;
2225
2326/**
@@ -42,6 +45,23 @@ public class PrometheusProperties {
4245 */
4346 private boolean descriptions = true ;
4447
48+ /**
49+ * Configuration options for using Prometheus Pushgateway, allowing metrics to be
50+ * pushed when they cannot be scraped.
51+ */
52+ private final Pushgateway pushgateway = new Pushgateway ();
53+
54+ /**
55+ * Histogram type for backing DistributionSummary and Timer.
56+ */
57+ @ Deprecated (since = "3.3.0" )
58+ private HistogramFlavor histogramFlavor = HistogramFlavor .Prometheus ;
59+
60+ /**
61+ * Additional properties to pass to the Prometheus client.
62+ */
63+ private final Map <String , String > prometheusProperties = new HashMap <>();
64+
4565 /**
4666 * Step size (i.e. reporting frequency) to use.
4767 */
@@ -55,6 +75,14 @@ public void setDescriptions(boolean descriptions) {
5575 this .descriptions = descriptions ;
5676 }
5777
78+ public HistogramFlavor getHistogramFlavor () {
79+ return this .histogramFlavor ;
80+ }
81+
82+ public void setHistogramFlavor (HistogramFlavor histogramFlavor ) {
83+ this .histogramFlavor = histogramFlavor ;
84+ }
85+
5886 public Duration getStep () {
5987 return this .step ;
6088 }
@@ -71,4 +99,132 @@ public void setEnabled(boolean enabled) {
7199 this .enabled = enabled ;
72100 }
73101
102+ public Pushgateway getPushgateway () {
103+ return this .pushgateway ;
104+ }
105+
106+ public Map <String , String > getPrometheusProperties () {
107+ return this .prometheusProperties ;
108+ }
109+
110+ /**
111+ * Configuration options for push-based interaction with Prometheus.
112+ */
113+ public static class Pushgateway {
114+
115+ /**
116+ * Enable publishing over a Prometheus Pushgateway.
117+ */
118+ private Boolean enabled = false ;
119+
120+ /**
121+ * Base URL for the Pushgateway.
122+ */
123+ private String baseUrl = "http://localhost:9091" ;
124+
125+ /**
126+ * Login user of the Prometheus Pushgateway.
127+ */
128+ private String username ;
129+
130+ /**
131+ * Login password of the Prometheus Pushgateway.
132+ */
133+ private String password ;
134+
135+ /**
136+ * Frequency with which to push metrics.
137+ */
138+ private Duration pushRate = Duration .ofMinutes (1 );
139+
140+ /**
141+ * Job identifier for this application instance.
142+ */
143+ private String job ;
144+
145+ /**
146+ * Grouping key for the pushed metrics.
147+ */
148+ private Map <String , String > groupingKey = new HashMap <>();
149+
150+ /**
151+ * Operation that should be performed on shutdown.
152+ */
153+ private ShutdownOperation shutdownOperation = ShutdownOperation .NONE ;
154+
155+ public Boolean getEnabled () {
156+ return this .enabled ;
157+ }
158+
159+ public void setEnabled (Boolean enabled ) {
160+ this .enabled = enabled ;
161+ }
162+
163+ public String getBaseUrl () {
164+ return this .baseUrl ;
165+ }
166+
167+ public void setBaseUrl (String baseUrl ) {
168+ this .baseUrl = baseUrl ;
169+ }
170+
171+ public String getUsername () {
172+ return this .username ;
173+ }
174+
175+ public void setUsername (String username ) {
176+ this .username = username ;
177+ }
178+
179+ public String getPassword () {
180+ return this .password ;
181+ }
182+
183+ public void setPassword (String password ) {
184+ this .password = password ;
185+ }
186+
187+ public Duration getPushRate () {
188+ return this .pushRate ;
189+ }
190+
191+ public void setPushRate (Duration pushRate ) {
192+ this .pushRate = pushRate ;
193+ }
194+
195+ public String getJob () {
196+ return this .job ;
197+ }
198+
199+ public void setJob (String job ) {
200+ this .job = job ;
201+ }
202+
203+ public Map <String , String > getGroupingKey () {
204+ return this .groupingKey ;
205+ }
206+
207+ public void setGroupingKey (Map <String , String > groupingKey ) {
208+ this .groupingKey = groupingKey ;
209+ }
210+
211+ public ShutdownOperation getShutdownOperation () {
212+ return this .shutdownOperation ;
213+ }
214+
215+ public void setShutdownOperation (ShutdownOperation shutdownOperation ) {
216+ this .shutdownOperation = shutdownOperation ;
217+ }
218+
219+ }
220+
221+ public enum HistogramFlavor {
222+
223+ Prometheus , VictoriaMetrics ;
224+
225+ HistogramFlavor () {
226+ }
227+
228+ }
229+
74230}
0 commit comments