@@ -114,32 +114,27 @@ ParseResult parseNameAndUnit(final String name) {
114
114
@ Override
115
115
public List <Record > parse (final HttpRequest data ) throws ParsingException {
116
116
final List <Record > records = Lists .newArrayList ();
117
- final byte [] uncompressed ;
118
- try {
119
- final byte [] input = data .getBody ().toArray ();
120
- if (_outputDebugInfo ) {
121
- final int outputFile = _outputFileNumber .incrementAndGet ();
122
- if (outputFile < 10 ) {
123
- Files .write (Paths .get ("prometheus_debug_" + outputFile ), input );
124
- }
125
- }
126
- uncompressed = Snappy .uncompress (input );
127
- } catch (final IOException e ) {
128
- throw new ParsingException ("Failed to decompress snappy stream" , data .getBody ().toArray (), e );
129
- }
117
+ final byte [] uncompressed = decompress (data );
130
118
try {
131
119
final Remote .WriteRequest writeRequest = Remote .WriteRequest .parseFrom (uncompressed );
132
120
for (final TimeSeries timeSeries : writeRequest .getTimeseriesList ()) {
121
+ boolean skipSeries = false ;
133
122
Optional <String > nameOpt = Optional .empty ();
134
123
final ImmutableMap .Builder <String , String > dimensionsBuilder = ImmutableMap .builder ();
135
124
for (final Types .Label label : timeSeries .getLabelsList ()) {
136
125
if ("__name__" .equals (label .getName ())) {
137
126
final String value = label .getValue ();
138
127
nameOpt = Optional .ofNullable (value );
128
+ } else if ("le" .equals (label .getName ())) {
129
+ skipSeries = true ;
139
130
} else {
140
131
dimensionsBuilder .put (label .getName (), label .getValue ());
141
132
}
142
133
}
134
+
135
+ if (skipSeries ) {
136
+ continue ;
137
+ }
143
138
final ParseResult result = parseNameAndUnit (nameOpt .orElse ("" ).trim ());
144
139
final String metricName = result .getName ();
145
140
if (metricName .isEmpty ()) {
@@ -172,6 +167,23 @@ public List<Record> parse(final HttpRequest data) throws ParsingException {
172
167
return records ;
173
168
}
174
169
170
+ private byte [] decompress (final HttpRequest data ) throws ParsingException {
171
+ final byte [] uncompressed ;
172
+ try {
173
+ final byte [] input = data .getBody ().toArray ();
174
+ if (_outputDebugInfo ) {
175
+ final int outputFile = _outputFileNumber .incrementAndGet ();
176
+ if (outputFile < 10 ) {
177
+ Files .write (Paths .get ("prometheus_debug_" + outputFile ), input );
178
+ }
179
+ }
180
+ uncompressed = Snappy .uncompress (input );
181
+ } catch (final IOException e ) {
182
+ throw new ParsingException ("Failed to decompress snappy stream" , data .getBody ().toArray (), e );
183
+ }
184
+ return uncompressed ;
185
+ }
186
+
175
187
private ImmutableMap <String , ? extends Metric > createMetric (final String name , final Types .Sample sample , final Optional <Unit > unit ) {
176
188
final Metric metric = ThreadLocalBuilder .build (
177
189
DefaultMetric .Builder .class ,
0 commit comments