@@ -100,6 +100,13 @@ static int collect_metrics(struct prom_scrape *ctx)
100100
101101 flb_http_buffer_size (c , ctx -> buffer_max_size );
102102
103+ /* Auth headers */
104+ if (ctx -> http_user && ctx -> http_passwd ) { /* Basic */
105+ flb_http_basic_auth (c , ctx -> http_user , ctx -> http_passwd );
106+ } else if (ctx -> bearer_token ) { /* Bearer token */
107+ flb_http_bearer_auth (c , ctx -> bearer_token );
108+ }
109+
103110 ret = flb_http_do (c , & b_sent );
104111 if (ret != 0 ) {
105112 flb_plg_error (ctx -> ins , "http do error" );
@@ -218,6 +225,24 @@ static struct flb_config_map config_map[] = {
218225 "Set the metrics URI endpoint, it must start with a forward slash."
219226 },
220227
228+ {
229+ FLB_CONFIG_MAP_STR , "http_user" , NULL ,
230+ 0 , FLB_TRUE , offsetof(struct prom_scrape , http_user ),
231+ "Set HTTP auth user"
232+ },
233+
234+ {
235+ FLB_CONFIG_MAP_STR , "http_passwd" , "" ,
236+ 0 , FLB_TRUE , offsetof(struct prom_scrape , http_passwd ),
237+ "Set HTTP auth password"
238+ },
239+
240+ {
241+ FLB_CONFIG_MAP_STR , "bearer_token" , NULL ,
242+ 0 , FLB_TRUE , offsetof(struct prom_scrape , bearer_token ),
243+ "Set bearer token auth"
244+ },
245+
221246 /* EOF */
222247 {0 }
223248};
0 commit comments