001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite;
018
019import java.time.Duration;
020import java.util.concurrent.TimeUnit;
021
022import io.micrometer.graphite.GraphiteProtocol;
023
024import org.springframework.boot.context.properties.ConfigurationProperties;
025
026/**
027 * {@link ConfigurationProperties} for configuring Graphite metrics export.
028 *
029 * @author Jon Schneider
030 * @author Stephane Nicoll
031 * @since 2.0.0
032 */
033@ConfigurationProperties(prefix = "management.metrics.export.graphite")
034public class GraphiteProperties {
035
036        /**
037         * Whether exporting of metrics to Graphite is enabled.
038         */
039        private boolean enabled = true;
040
041        /**
042         * Step size (i.e. reporting frequency) to use.
043         */
044        private Duration step = Duration.ofMinutes(1);
045
046        /**
047         * Base time unit used to report rates.
048         */
049        private TimeUnit rateUnits = TimeUnit.SECONDS;
050
051        /**
052         * Base time unit used to report durations.
053         */
054        private TimeUnit durationUnits = TimeUnit.MILLISECONDS;
055
056        /**
057         * Host of the Graphite server to receive exported metrics.
058         */
059        private String host = "localhost";
060
061        /**
062         * Port of the Graphite server to receive exported metrics.
063         */
064        private Integer port = 2004;
065
066        /**
067         * Protocol to use while shipping data to Graphite.
068         */
069        private GraphiteProtocol protocol = GraphiteProtocol.PICKLED;
070
071        /**
072         * For the default naming convention, turn the specified tag keys into part of the
073         * metric prefix.
074         */
075        private String[] tagsAsPrefix = new String[0];
076
077        public boolean isEnabled() {
078                return this.enabled;
079        }
080
081        public void setEnabled(boolean enabled) {
082                this.enabled = enabled;
083        }
084
085        public Duration getStep() {
086                return this.step;
087        }
088
089        public void setStep(Duration step) {
090                this.step = step;
091        }
092
093        public TimeUnit getRateUnits() {
094                return this.rateUnits;
095        }
096
097        public void setRateUnits(TimeUnit rateUnits) {
098                this.rateUnits = rateUnits;
099        }
100
101        public TimeUnit getDurationUnits() {
102                return this.durationUnits;
103        }
104
105        public void setDurationUnits(TimeUnit durationUnits) {
106                this.durationUnits = durationUnits;
107        }
108
109        public String getHost() {
110                return this.host;
111        }
112
113        public void setHost(String host) {
114                this.host = host;
115        }
116
117        public Integer getPort() {
118                return this.port;
119        }
120
121        public void setPort(Integer port) {
122                this.port = port;
123        }
124
125        public GraphiteProtocol getProtocol() {
126                return this.protocol;
127        }
128
129        public void setProtocol(GraphiteProtocol protocol) {
130                this.protocol = protocol;
131        }
132
133        public String[] getTagsAsPrefix() {
134                return this.tagsAsPrefix;
135        }
136
137        public void setTagsAsPrefix(String[] tagsAsPrefix) {
138                this.tagsAsPrefix = tagsAsPrefix;
139        }
140
141}