@@ -207,12 +207,12 @@ func (c *VPCCollector) collectRoutesPerRouteTableUsage(ch chan<- prometheus.Metr
207207 descRouteTableOutput , err := c .ec2 .DescribeRouteTablesWithContext (ctx , & ec2.DescribeRouteTablesInput {
208208 RouteTableIds : []* string {rtb .RouteTableId },
209209 })
210- if err != nil {
210+ if err != nil || len ( descRouteTableOutput . RouteTables ) != 1 {
211211 level .Error (c .e .logger ).Log ("msg" , "Call to DescribeRouteTables failed" , "region" , c .region , "err" , err )
212212 exporterMetrics .IncrementErrors ()
213213 return
214214 }
215- quota := len (descRouteTableOutput .RouteTables )
215+ quota := len (descRouteTableOutput .RouteTables [ 0 ]. Routes )
216216 ch <- prometheus .MustNewConstMetric (c .e .RoutesPerRouteTableUsage , prometheus .GaugeValue , float64 (quota ), * c .region , * rtb .VpcId , * rtb .RouteTableId )
217217}
218218
@@ -229,19 +229,33 @@ func (c *VPCCollector) collectInterfaceVpcEndpointsPerVpcQuota(ch chan<- prometh
229229func (c * VPCCollector ) collectInterfaceVpcEndpointsPerVpcUsage (ch chan <- prometheus.Metric , vpc * ec2.Vpc ) {
230230 ctx , cancelFunc := context .WithTimeout (context .Background (), c .e .timeout )
231231 defer cancelFunc ()
232- descVpcEndpoints , err := c .ec2 .DescribeVpcEndpointsWithContext (ctx , & ec2.DescribeVpcEndpointsInput {
233- Filters : []* ec2.Filter {{
234- Name : aws .String ("vpc-id" ),
235- Values : []* string {vpc .VpcId },
236- }},
237- })
232+
233+ numEndpoints := 0
234+ descEndpointsInput := & ec2.DescribeVpcEndpointsInput {
235+ Filters : []* ec2.Filter {{Name : aws .String ("vpc-id" ), Values : []* string {vpc .VpcId }}},
236+ MaxResults : aws .Int64 (1000 ),
237+ }
238+
239+ descEndpointsOutput , err := c .ec2 .DescribeVpcEndpointsWithContext (ctx , descEndpointsInput )
238240 if err != nil {
239241 level .Error (c .e .logger ).Log ("msg" , "Call to DescribeVpcEndpoints failed" , "region" , c .region , "err" , err )
240242 exporterMetrics .IncrementErrors ()
241243 return
242244 }
243- quota := len (descVpcEndpoints .VpcEndpoints )
244- ch <- prometheus .MustNewConstMetric (c .e .InterfaceVpcEndpointsPerVpcUsage , prometheus .GaugeValue , float64 (quota ), * c .region , * vpc .VpcId )
245+ numEndpoints += len (descEndpointsOutput .VpcEndpoints )
246+
247+ for descEndpointsOutput .NextToken != nil {
248+ descEndpointsInput .SetNextToken (* descEndpointsOutput .NextToken )
249+ descEndpointsOutput , err = c .ec2 .DescribeVpcEndpointsWithContext (ctx , descEndpointsInput )
250+ if err != nil {
251+ level .Error (c .e .logger ).Log ("msg" , "Call to DescribeVpcEndpoints failed" , "region" , * c .region , "err" , err )
252+ exporterMetrics .IncrementErrors ()
253+ return
254+ }
255+ numEndpoints += len (descEndpointsOutput .VpcEndpoints )
256+ }
257+
258+ ch <- prometheus .MustNewConstMetric (c .e .InterfaceVpcEndpointsPerVpcUsage , prometheus .GaugeValue , float64 (numEndpoints ), * c .region , * vpc .VpcId )
245259}
246260
247261func (c * VPCCollector ) collectRoutesTablesPerVpcQuota (ch chan <- prometheus.Metric ) {
0 commit comments