[ 
https://issues.apache.org/jira/browse/KARAF-7841?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17900303#comment-17900303
 ] 

ASF GitHub Bot commented on KARAF-7841:
---------------------------------------

jbonofre commented on code in PR #337:
URL: https://github.com/apache/karaf-decanter/pull/337#discussion_r1853644847


##########
pom.xml:
##########
@@ -538,6 +538,7 @@
                                 <exclude>**/*.svg</exclude>
                                 <exclude>**/*.less</exclude>
                                 <exclude>**/build.txt</exclude>
+                                <exclude>**/sample.txt</exclude>

Review Comment:
   OK fair enough.



##########
collector/prometheus/src/main/java/org/apache/karaf/decanter/collector/prometheus/PrometheusCollector.java:
##########
@@ -71,28 +73,39 @@ public void activate(Dictionary<String, Object> properties) 
throws Exception {
     public void run() {
         try {
             URLConnection connection = prometheusURL.openConnection();
-            Map<String, Object> data = new HashMap<>();
-            data.put("type", "prometheus");
+            String topic = (properties.get(EventConstants.EVENT_TOPIC) != 
null) ? (String) properties.get(EventConstants.EVENT_TOPIC) : 
"decanter/collect/prometheus";

Review Comment:
   Just a reminder:  it's possible to override via configuration, in 
`etc/org.apache.karaf.decanter.collector.prometheus.cfg`:
   
   ```
   event.topics=/foo/bar
   ```
   
   It's documented here 
https://karaf.apache.org/manual/decanter/latest-2/html/#_alerters in the "Using 
existing appenders".



##########
collector/prometheus/src/main/java/org/apache/karaf/decanter/collector/prometheus/PrometheusCollector.java:
##########
@@ -71,28 +73,39 @@ public void activate(Dictionary<String, Object> properties) 
throws Exception {
     public void run() {
         try {
             URLConnection connection = prometheusURL.openConnection();
-            Map<String, Object> data = new HashMap<>();
-            data.put("type", "prometheus");
+            String topic = (properties.get(EventConstants.EVENT_TOPIC) != 
null) ? (String) properties.get(EventConstants.EVENT_TOPIC) : 
"decanter/collect/prometheus";
+            String type = (properties.get("type") != null) ? (String) 
properties.get("type") : "prometheus";

Review Comment:
   Same, already possible.
   
   That said, I think it's important to have consistency in `type`, so why not 
having hardcoded `type` here.



##########
collector/prometheus/src/test/resources/sample.txt:
##########
@@ -1,27 +1,13 @@
-<!--

Review Comment:
   rat won't be happy without the ASF header here, or we have to exclude it.





> Use Prometheus labels and create 1 event per metric in the 
> Prometheus-Collector
> -------------------------------------------------------------------------------
>
>                 Key: KARAF-7841
>                 URL: https://issues.apache.org/jira/browse/KARAF-7841
>             Project: Karaf
>          Issue Type: Improvement
>          Components: decanter
>    Affects Versions: decanter-2.10.0
>            Reporter: Francois Papon
>            Assignee: Francois Papon
>            Priority: Major
>             Fix For: decanter-2.11.0
>
>
> We should be able to parse labels in Prometheus metric like:
> {code:java}
> # HELP request_time_total
> # TYPE request_time_total counter
> request_time_total_seconds{api="my-api",endpoint="/send",method="POST"} 1.0
> # HELP memoryPool_usage_bytes Current usage of the memory pool
> # TYPE memoryPool_usage_bytes gauge
> memoryPool_usage_bytes{name="Compressed Class Space"} 2.2561752E7
> memoryPool_usage_bytes{name="G1 Eden Space"} 1.2582912E7{code}
> The purpose is to store each labels as an event data property.
> We also should create 1 event per metric.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to