This is an automated email from the ASF dual-hosted git repository.

guoyp pushed a commit to branch griffin-2.0.0-dev
in repository https://gitbox.apache.org/repos/asf/griffin.git


The following commit(s) were added to refs/heads/griffin-2.0.0-dev by this push:
     new ec2d02cb Metric (#671)
ec2d02cb is described below

commit ec2d02cbe3653cb421b66466526d59bbe00ea2b4
Author: Jin <[email protected]>
AuthorDate: Mon Dec 9 14:02:37 2024 +0800

    Metric (#671)
    
    * add service interface for metricD table.
    
    * add the process of exception.
    
    * add the document of metric service.
---
 griffin-doc/dev-2/new-metric-build.md              | 142 +++++++++++++++++++++
 .../{application.yaml => application-dev.yaml}     |  23 +---
 .../{application.yaml => application-prod.yaml}    |  36 ++----
 griffin-metric/src/main/resources/application.yaml |  55 +-------
 4 files changed, 158 insertions(+), 98 deletions(-)

diff --git a/griffin-doc/dev-2/new-metric-build.md 
b/griffin-doc/dev-2/new-metric-build.md
new file mode 100644
index 00000000..da252677
--- /dev/null
+++ b/griffin-doc/dev-2/new-metric-build.md
@@ -0,0 +1,142 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## Abstract
+Apache Griffin 2.0 is a new generation of Data Service Platform.Compared to 
Griffin 1.0, new version aims to provide a
+more decouple service framework, including griffin-connectors, griffin-metric, 
griffin-dqc, griffin-scheduler. 
+
+Here, we will give much more details about griffin-metric.
+
+## Apache Griffin Metric
+You can use dev profile to verify the metric API.  
+1. Edit the configuration file 
griffin-metric/src/main/resources/application.yaml
+```yaml
+spring:
+  profiles:
+    active: dev # set effective configuration to application-dev.yaml
+```
+2. Run the metric service
+```shell
+$JAVA_HOME/bin/java -cp <classpath> org.apache.griffin.metric.DAOApplication
+```
+3. Check the H2 memory database
+```shell
+Explore http://localhost:8888/h2-console by the broswer
+
+Fill 'JDBC URL' with 'jdbc:h2:mem:griffin'
+
+Click the button 'Connect'
+
+You can see four tables:
+T_METRIC_D 
+T_METRIC_V
+T_METRIC_TAG  
+T_TAG_D 
+```
+4. Call REST APIs
+   1. Query all metric definitions
+       ```shell
+       GET http://localhost:8888/allMetricDs
+      
+         Response:
+         [
+            {
+               "metricId": 1,
+               "metricName": "latency",
+               "owner": "admin",
+               "description": "test metric",
+               "creation_time": "2024-11-29T03:17:06.671+00:00",
+               "update_time": "2024-11-29T03:17:06.671+00:00"
+            }
+         ]
+       ```
+   2. Define a new metric
+      ```shell
+        PUT http://localhost:8888/metricD
+        Content-Type: application/json
+        {
+           "description": "test metric",
+           "metricName": "latency",
+           "owner": "admin"
+        }
+       
+        Response:
+        {
+           "metricId": 1,
+           "metricName": "latency",
+           "owner": "admin",
+           "description": "test metric"
+        }
+        ```
+   3. Set the value of a metric 
+        ```shell
+        PUT http://localhost:8888/metricV
+        Content-Type: application/json
+      
+        {
+           "metricId": 1,
+           "value": 5,
+           "ctime": "",
+           "mtime": ""
+        }
+      
+        Response:
+        {
+           "metricId": 1,
+           "value": 5.0
+        }
+        ```
+   4. Define a metric tag
+        ```shell
+        PUT http://localhost:8888/metricTagD
+      Content-Type: application/json
+      
+      {
+          "tagKey": "perf",
+          "tagValue": "0.0"
+      }
+   
+        Response:
+        {
+            "id": 1,
+            "tagKey": "perf",
+            "tagValue": "0.0"
+      }
+        ```
+   5. Tag a metric definition
+      ```shell
+       PUT http://localhost:8888/tags
+       Content-Type: application/json
+
+      {
+      "metricId": 1,
+      "tagId": 1
+      }
+      
+      Response:
+      {
+      "metricId": 1,
+      "tagId": 1
+      }
+      ```
+   5. Delete a metric definition
+      ```shell
+      DELETE http://localhost:8888/metricD/{id}
+      ```
+
diff --git a/griffin-metric/src/main/resources/application.yaml 
b/griffin-metric/src/main/resources/application-dev.yaml
similarity index 80%
copy from griffin-metric/src/main/resources/application.yaml
copy to griffin-metric/src/main/resources/application-dev.yaml
index 85a33f8c..4fff1663 100644
--- a/griffin-metric/src/main/resources/application.yaml
+++ b/griffin-metric/src/main/resources/application-dev.yaml
@@ -20,16 +20,6 @@ server:
 spring:
   application:
     name: persist-service
-#  sql:
-#    init:
-#      schema-locations: classpath:sql/create_mysql.sql
-#  datasource:
-#    driver-class-name: com.mysql.cj.jdbc.Driver
-#    url: jdbc:mysql://127.0.0.1:3306/griffin
-#    username: root
-#    password: ""
-#    hikari:
-#      maximum-pool-size: 5
   sql:
     init:
       schema-locations: classpath:sql/create_h2.sql
@@ -37,7 +27,7 @@ spring:
       mode: embedded
   datasource:
     driver-class-name: org.h2.Driver
-    url: jdbc:h2:mem:griffin
+    url: jdbc:h2:mem:griffin # configure in-memory database
     username: sa
     password: ""
     hikari:
@@ -45,8 +35,8 @@ spring:
 
   h2:
     console:
-      path: /h2-console
-      enabled: on
+      path: /h2-console # configure the path of h2 console
+      enabled: on # start up the h2 console
       settings:
         web-allow-others: true
         trace: true
@@ -64,7 +54,6 @@ mybatis-plus:
       id-type: auto
     banner: false
 
-
-#logging:
-#  level:
-#    root: DEBUG
\ No newline at end of file
+logging:
+  level:
+    root: info
\ No newline at end of file
diff --git a/griffin-metric/src/main/resources/application.yaml 
b/griffin-metric/src/main/resources/application-prod.yaml
old mode 100644
new mode 100755
similarity index 66%
copy from griffin-metric/src/main/resources/application.yaml
copy to griffin-metric/src/main/resources/application-prod.yaml
index 85a33f8c..29a165fb
--- a/griffin-metric/src/main/resources/application.yaml
+++ b/griffin-metric/src/main/resources/application-prod.yaml
@@ -15,42 +15,22 @@
 # limitations under the License.
 #
 server:
-  port: 8888
+  port: 8080
 
 spring:
   application:
     name: persist-service
-#  sql:
-#    init:
-#      schema-locations: classpath:sql/create_mysql.sql
-#  datasource:
-#    driver-class-name: com.mysql.cj.jdbc.Driver
-#    url: jdbc:mysql://127.0.0.1:3306/griffin
-#    username: root
-#    password: ""
-#    hikari:
-#      maximum-pool-size: 5
   sql:
     init:
-      schema-locations: classpath:sql/create_h2.sql
-      continue-on-error: false
-      mode: embedded
+      schema-locations: classpath:sql/create_mysql.sql
   datasource:
-    driver-class-name: org.h2.Driver
-    url: jdbc:h2:mem:griffin
-    username: sa
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://127.0.0.1:3306/griffin
+    username: root
     password: ""
     hikari:
       maximum-pool-size: 5
 
-  h2:
-    console:
-      path: /h2-console
-      enabled: on
-      settings:
-        web-allow-others: true
-        trace: true
-
 mybatis-plus:
   mapper-locations: classpath:mapper/*Mapper.xml
   type-aliases-package: org.apache.griffin.metric.dao.entity
@@ -65,6 +45,6 @@ mybatis-plus:
     banner: false
 
 
-#logging:
-#  level:
-#    root: DEBUG
\ No newline at end of file
+logging:
+  level:
+    root: info
\ No newline at end of file
diff --git a/griffin-metric/src/main/resources/application.yaml 
b/griffin-metric/src/main/resources/application.yaml
old mode 100644
new mode 100755
index 85a33f8c..c8bb990b
--- a/griffin-metric/src/main/resources/application.yaml
+++ b/griffin-metric/src/main/resources/application.yaml
@@ -14,57 +14,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-server:
-  port: 8888
-
 spring:
-  application:
-    name: persist-service
-#  sql:
-#    init:
-#      schema-locations: classpath:sql/create_mysql.sql
-#  datasource:
-#    driver-class-name: com.mysql.cj.jdbc.Driver
-#    url: jdbc:mysql://127.0.0.1:3306/griffin
-#    username: root
-#    password: ""
-#    hikari:
-#      maximum-pool-size: 5
-  sql:
-    init:
-      schema-locations: classpath:sql/create_h2.sql
-      continue-on-error: false
-      mode: embedded
-  datasource:
-    driver-class-name: org.h2.Driver
-    url: jdbc:h2:mem:griffin
-    username: sa
-    password: ""
-    hikari:
-      maximum-pool-size: 5
-
-  h2:
-    console:
-      path: /h2-console
-      enabled: on
-      settings:
-        web-allow-others: true
-        trace: true
-
-mybatis-plus:
-  mapper-locations: classpath:mapper/*Mapper.xml
-  type-aliases-package: org.apache.griffin.metric.dao.entity
-  configuration:
-    cache-enabled: false
-    call-setters-on-nulls: true
-    map-underscore-to-camel-case: true
-    jdbc-type-for-null: NULL
-  global-config:
-    db-config:
-      id-type: auto
-    banner: false
-
-
-#logging:
-#  level:
-#    root: DEBUG
\ No newline at end of file
+  profiles:
+    active: dev
\ No newline at end of file

Reply via email to