Repository: apache/skywalking (language: python)

Issue:
MySQL/PostgreSQL monitor should be able to support cluster mode scenario
### Search before asking

- [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar feature requirement.


### Description

In recent pull requests from @yswdqz we can monitor metrics from MySQL and PostgreSQL, but currently we assume that every MySQL/PostgreSQL server only has one instance, and we use that instance as the service name, (refer to our demo environment http://demo.skywalking.apache.org/mySQL)

<img width="1182" alt="image" src="https://user-images.githubusercontent.com/15965696/195023145-784519cb-af23-4736-b9dc-cdc87862f11d.png">

However, a MySQL/PostgreSQL server should be able to have multiple instances and form a cluster, in that case, we should have aggregated metrics for those instances.

### Use case

When there are multiple instances/nodes for one MySQL/PostgreSQL server, users can have an aggregated overview of the database server.

### Related issues

_No response_

### Are you willing to submit a PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)



Discussion / hints:
@yswdqz I can't assign this to you YET, are you willing to continue this?
@yswdqz I think we could have perf of both k8s service and per pod(as skywalking instance level).

We had a similar discussion with @pg-yang from https://github.com/apache/skywalking-showcase/pull/83#issuecomment-1272504487. Generally about the same preferences. 
Yes, I will.
But I am doing another PR now, might be doing this later.
If you mean the SQL-sign, I think you don't need to hurry. After all, I could image that is a long-term feature, we may face forward and backward several times, also be struggling due to the tradeoff :)
> If you mean the SQL-sign, I think you don't need to hurry. After all, I could image that is a long-term feature, we may face forward and backward several times, also be struggling due to the tradeoff :)

Got it.
@yswdqz How is this going?
> @yswdqz How is this going?

I haven't started it yet ( because of something about my university ). I will start it tomorrow.

By the way, Does this mean that I should set what I previously set as `service` to `instance` and then set the cluster's metrics to `service`?

Yes, each IP/pod should be an instance.
Got it.
I am comfused about which metrics should I to set for cluster because there are many kind of cluster (such as galera, MMM) and  It's hard to find good metrics/exporter for most of them.
And is this issue ("have an aggregated overview of the database server") means that I just need to set service lever dashboards the same as instance level?
> I am comfused about which metrics should I to set for cluster because there are many kind of cluster (such as galera, MMM) and  It's hard to find good metrics/exporter for most of them.
> 
> And is this issue ("have an aggregated overview of the database server") means that I just need to set service lever dashboards the same as instance level?

The service name should be set by users in a label `service`. Usually they should set this to the business usage such as `product1`, `product2`
About which metrics, I think there would not have much difference. When you set up a MySQL service in prod env, usually there is read/write or master/slave deployment for a database to provide HA or higher performance. 
This is generally why Zhenxu asked you to monitoring MySQL from a service perspective rather than currently from a single MySQL node(instance) perspective.
> About which metrics, I think there would not have much difference. When you set up a MySQL service in prod env, usually there is read/write or master/slave deployment for a database to provide HA or higher performance. This is generally why Zhenxu asked you to monitoring MySQL from a service perspective rather than currently from a single MySQL node(instance) perspective.

So the slow sql monitoring should be service level(not instance level)?
I think we only support slow SQL at service for now.

I just talked with @mrproliu about extending sampled records for various entity level, even for relationship.

FYI @Fine0830 We may need to adjust sampled record widget as well.
To confirm, do I need to wait for the new pr to be submitted or temporarily set slowsql to service level?
> temporarily set slowsql to service level?

This should be good enough for now.
> > temporarily set slowsql to service level?
> 
> This should be good enough for now.

Got it.
![image](https://user-images.githubusercontent.com/74546965/196459493-2473b6bd-1787-4945-80f9-c78387f5f286.png)
This is the service level design. Is that OK ?
Inspections : show metrics
Slow Stetement: shiow slowsql statements;
Instances: show instances of this service.

And I remove the instance level's Slow Statement. Now Slow Statement only exist in service level.
Make sense to me.
MySQL - Service:
![image](https://user-images.githubusercontent.com/74546965/200229086-5a43f535-4860-42fb-9664-1c77fb23c9ee.png)
![image](https://user-images.githubusercontent.com/74546965/200229147-2dc04a36-3d9d-4e9a-8e01-4ea0fda8c21c.png)
MySQL - Instance:
![image](https://user-images.githubusercontent.com/74546965/200231187-62b3fb64-d968-4b1b-9110-6242d338cf02.png)

Is that ok?
> And I remove the instance level's Slow Statement. Now Slow Statement only exist in service level.

Hi, why do you think we should remove Slow Statements in instance level?

The other screenshots looks good to me
For now instance level Slow Statements is not supported.
> For now instance level Slow Statements is not supported.

Do you mean UI component doesn't support instance level Slow Statement? 
> > temporarily set slowsql to service level?
> 
> This should be good enough for now.

It is not supported by LAL slow sql spec, too. I used to think the service level was enough. If it is needed, I can change the LAL part.

> > > temporarily set slowsql to service level?
> > 
> > 
> > This should be good enough for now.
> 
> It is not supported by LAL slow sql spec, too. I used to think the service level was enough. If it is needed, I can change the LAL part.

OK, let's only support service level for now

Fix patch:
diff --git a/apm-dist/src/main/assembly/binary.xml b/apm-dist/src/main/assembly/binary.xml
index 259f72127230..f3c84eb2dee4 100644
--- a/apm-dist/src/main/assembly/binary.xml
+++ b/apm-dist/src/main/assembly/binary.xml
@@ -61,14 +61,14 @@
                 <include>trace-sampling-policy-settings.yml</include>
                 <include>oal/*.oal</include>
                 <include>fetcher-prom-rules/*.yaml</include>
-                <include>envoy-metrics-rules/*.yaml</include>
+                <include>envoy-metrics-rules/**</include>
                 <include>meter-analyzer-config/*.yaml</include>
                 <include>zabbix-rules/*.yaml</include>
                 <include>openapi-definitions/*/*.yaml</include>
                 <include>otel-rules/**</include>
                 <include>ui-initialized-templates/*/*.json</include>
                 <include>lal/*</include>
-                <include>log-mal-rules/*</include>
+                <include>log-mal-rules/**</include>
                 <include>telegraf-rules/*</include>
             </includes>
             <outputDirectory>config</outputDirectory>
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 1d0b44d30467..8ad0514bc04d 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -83,6 +83,7 @@
 * Support `sampledTrace` in LAL.
 * Support multiple rules with different names under the same layer of LAL script.
 * (Optimization) Reduce the buffer size(queue) of MAL(only) metric streams. Set L1 queue size as 1/20, L2 queue size as 1/2.
+* Support monitoring MySQL/PostgreSQL in the cluster mode.
 * [**Breaking Change**] Migrate to BanyanDB v0.2.0.
   * Adopt new OR logical operator for,
     1. `MeasureIDs` query
diff --git a/docs/en/setup/backend/backend-mysql-monitoring.md b/docs/en/setup/backend/backend-mysql-monitoring.md
index c1f368f48976..cfb4ffaea369 100644
--- a/docs/en/setup/backend/backend-mysql-monitoring.md
+++ b/docs/en/setup/backend/backend-mysql-monitoring.md
@@ -14,7 +14,8 @@ SkyWalking leverages prometheus/mysqld_exporter for collecting metrics data. It
 3. Config SkyWalking [OpenTelemetry receiver](opentelemetry-receiver.md).
 
 ### MySQL Monitoring
-MySQL monitoring provides monitoring of the status and resources of the MySQL server. MySQL server is cataloged as a `Layer: MYSQL` `Service` in OAP.
+MySQL monitoring provides monitoring of the status and resources of the MySQL server. MySQL cluster is cataloged as a `Layer: MYSQL` `Service` in OAP.
+Each MySQL server is cataloged as an `Instance` in OAP.
 #### Supported Metrics 
 | Monitoring Panel | Unit | Metric Name | Description | Data Source |
 |-----|------|-----|-----|-----|
diff --git a/docs/en/setup/backend/backend-postgresql-monitoring.md b/docs/en/setup/backend/backend-postgresql-monitoring.md
index 1956758c5cde..6f75e4882814 100644
--- a/docs/en/setup/backend/backend-postgresql-monitoring.md
+++ b/docs/en/setup/backend/backend-postgresql-monitoring.md
@@ -64,8 +64,8 @@ SkyWalking leverages [fluentbit](https://fluentbit.io/) or other log agents for
 3. Config PostgreSQL to enable slow log. [Example](../../../../test/e2e-v2/cases/postgresql/postgres-exporter/postgresql.conf).
 
 ### Slow SQL Monitoring
-Slow SQL monitoring provides monitoring of the slow SQL statements of the PostgreSQL server. PostgreSQL server is cataloged as a `Layer: POSTGRESQL` `Service` in OAP.
-
+Slow SQL monitoring provides monitoring of the slow SQL statements of the PostgreSQL server. PostgreSQL Cluster is cataloged as a `Layer: POSTGRESQL` `Service` in OAP.
+Each PostgreSQL server is cataloged as an `Instance` in OAP.
 #### Supported Metrics
 | Monitoring Panel | Unit | Metric Name | Description | Data Source |
 |-----|------|-----|-----|-----|
diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml
index aa1cf0493ec0..bc3af91b9497 100644
--- a/oap-server/server-starter/src/main/resources/application.yml
+++ b/oap-server/server-starter/src/main/resources/application.yml
@@ -356,7 +356,7 @@ receiver-otel:
   selector: ${SW_OTEL_RECEIVER:default}
   default:
     enabledHandlers: ${SW_OTEL_RECEIVER_ENABLED_HANDLERS:"oc,otlp"}
-    enabledOtelRules: ${SW_OTEL_RECEIVER_ENABLED_OTEL_RULES:"apisix,k8s/*,istio-controlplane,vm,mysql,postgresql,oap"}
+    enabledOtelRules: ${SW_OTEL_RECEIVER_ENABLED_OTEL_RULES:"apisix,k8s/*,istio-controlplane,vm,mysql/*,postgresql/*,oap"}
 
 receiver-zipkin:
   selector: ${SW_RECEIVER_ZIPKIN:-}
diff --git a/oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-instance.yaml b/oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-instance.yaml
new file mode 100644
index 000000000000..bbbbde476748
--- /dev/null
+++ b/oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-instance.yaml
@@ -0,0 +1,82 @@
+# 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.
+
+# This will parse a textual representation of a duration. The formats
+# accepted are based on the ISO-8601 duration format {@code PnDTnHnMn.nS}
+# with days considered to be exactly 24 hours.
+# <p>
+# Examples:
+# <pre>
+#    "PT20.345S" -- parses as "20.345 seconds"
+#    "PT15M"     -- parses as "15 minutes" (where a minute is 60 seconds)
+#    "PT10H"     -- parses as "10 hours" (where an hour is 3600 seconds)
+#    "P2D"       -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
+#    "P2DT3H4M"  -- parses as "2 days, 3 hours and 4 minutes"
+#    "P-6H3M"    -- parses as "-6 hours and +3 minutes"
+#    "-P6H3M"    -- parses as "-6 hours and -3 minutes"
+#    "-P-6H+3M"  -- parses as "+6 hours and -3 minutes"
+# </pre>
+filter: "{ tags -> tags.job_name == 'mysql-monitoring' }" # The OpenTelemetry job name
+expSuffix:  tag({tags -> tags.host_name = 'mysql::' + tags.host_name}).service(['host_name'] , Layer.MYSQL).instance(['host_name'], ['service_instance_id'], Layer.MYSQL)
+metricPrefix: meter_mysql
+metricsRules:
+  # mysql configurations
+  - name: instance_uptime
+    exp: mysql_global_status_uptime
+  - name: instance_innodb_buffer_pool_size
+    exp: mysql_global_variables_innodb_buffer_pool_size
+  - name: instance_max_connections
+    exp: mysql_global_variables_max_connections
+  - name: instance_thread_cache_size
+    exp: mysql_global_variables_thread_cache_size
+
+  # database throughput
+  - name: instance_commands_insert_rate
+    exp: mysql_global_status_commands_total.tagEqual('command','insert').rate('PT1M')
+  - name: instance_commands_select_rate
+    exp: mysql_global_status_commands_total.tagEqual('command','select').rate('PT1M')
+  - name: instance_commands_delete_rate
+    exp: mysql_global_status_commands_total.tagEqual('command','delete').rate('PT1M')
+  - name: instance_commands_update_rate
+    exp: mysql_global_status_commands_total.tagEqual('command','update').rate('PT1M')
+  - name: instance_qps
+    exp: mysql_global_status_queries.rate('PT1M')
+  - name: instance_tps
+    exp: mysql_global_status_commands_total.tagMatch('command','rollback|commit').rate('PT1M')
+
+  # connections
+  ## threads
+  - name: instance_threads_connected
+    exp: mysql_global_status_threads_connected
+  - name: instance_threads_created
+    exp: mysql_global_status_threads_created
+  - name: instance_threads_running
+    exp: mysql_global_status_threads_running
+  - name: instance_threads_cached
+    exp: mysql_global_status_threads_cached
+  ## connect
+  - name: instance_connects_aborted
+    exp: mysql_global_status_aborted_connects
+  - name: instance_connects_available
+    exp: mysql_global_variables_max_connections.sum(['host_name','service_instance_id']) - mysql_global_status_threads_connected.sum(['host_name','service_instance_id'])
+  - name: instance_connection_errors_max_connections
+    exp: mysql_global_status_connection_errors_total.tagEqual('error','max_connection')
+  - name: instance_connection_errors_internal
+    exp: mysql_global_status_connection_errors_total.tagEqual('error','internal')
+
+  # slow queries
+  - name: instance_slow_queries_rate
+    exp: mysql_global_status_slow_queries.rate('PT1M')
+
diff --git a/oap-server/server-starter/src/main/resources/otel-rules/mysql.yaml b/oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-service.yaml
similarity index 90%
rename from oap-server/server-starter/src/main/resources/otel-rules/mysql.yaml
rename to oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-service.yaml
index b41aad70feda..814f390d08bb 100644
--- a/oap-server/server-starter/src/main/resources/otel-rules/mysql.yaml
+++ b/oap-server/server-starter/src/main/resources/otel-rules/mysql/mysql-service.yaml
@@ -32,16 +32,6 @@ filter: "{ tags -> tags.job_name == 'mysql-monitoring' }" # The OpenTelemetry jo
 expSuffix:  tag({tags -> tags.host_name = 'mysql::' + tags.host_name}).service(['host_name'] , Layer.MYSQL)
 metricPrefix: meter_mysql
 metricsRules:
-  # mysql configurations
-  - name: uptime
-    exp: mysql_global_status_uptime
-  - name: innodb_buffer_pool_size
-    exp: mysql_global_variables_innodb_buffer_pool_size
-  - name: max_connections
-    exp: mysql_global_variables_max_connections
-  - name: thread_cache_size
-    exp: mysql_global_variables_thread_cache_size
-
   # database throughput
   - name: commands_insert_rate
     exp: mysql_global_status_commands_total.tagEqual('command','insert').rate('PT1M')
@@ -54,7 +44,7 @@ metricsRules:
   - name: qps
     exp: mysql_global_status_queries.rate('PT1M')
   - name: tps
-    exp: mysql_global_status_commands_total.tagMatch('command','rollback|commit').rate('PT1M')
+    exp: mysql_global_status_commands_total.tagMatch('command','rollback|commit').sum(['host_name']).rate('PT1M')
 
   # connections
   ## threads
diff --git a/oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-instance.yaml b/oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-instance.yaml
new file mode 100644
index 000000000000..b36349c0ffd1
--- /dev/null
+++ b/oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-instance.yaml
@@ -0,0 +1,115 @@
+# 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.
+
+# This will parse a textual representation of a duration. The formats
+# accepted are based on the ISO-8601 duration format {@code PnDTnHnMn.nS}
+# with days considered to be exactly 24 hours.
+# <p>
+# Examples:
+# <pre>
+#    "PT20.345S" -- parses as "20.345 seconds"
+#    "PT15M"     -- parses as "15 minutes" (where a minute is 60 seconds)
+#    "PT10H"     -- parses as "10 hours" (where an hour is 3600 seconds)
+#    "P2D"       -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
+#    "P2DT3H4M"  -- parses as "2 days, 3 hours and 4 minutes"
+#    "P-6H3M"    -- parses as "-6 hours and +3 minutes"
+#    "-P6H3M"    -- parses as "-6 hours and -3 minutes"
+#    "-P-6H+3M"  -- parses as "+6 hours and -3 minutes"
+# </pre>
+filter: "{ tags -> tags.job_name == 'postgresql-monitoring' }" # The OpenTelemetry job name
+expSuffix:  tag({tags -> tags.host_name = 'postgresql::' + tags.host_name}).service(['host_name'] , Layer.POSTGRESQL).instance(['host_name'],['service_instance_id'], Layer.POSTGRESQL)
+metricPrefix: meter_pg
+metricsRules:
+  # postgresql configurations
+  - name: instance_shared_buffers
+    exp: pg_settings_shared_buffers_bytes
+  - name: instance_effective_cache
+    exp: pg_settings_effective_cache_size_bytes
+  - name: instance_maintenance_work_mem
+    exp: pg_settings_maintenance_work_mem_bytes
+  - name: instance_work_mem
+    exp: pg_settings_work_mem_bytes
+  - name: instance_seq_page_cost
+    exp: pg_settings_seq_page_cost
+  - name: instance_random_page_cost
+    exp: pg_settings_random_page_cost
+  - name: instance_max_wal_size
+    exp: pg_settings_max_wal_size_bytes
+  - name: instance_max_parallel_workers
+    exp: pg_settings_max_parallel_workers
+  - name: instance_max_worker_processes
+    exp: pg_settings_max_worker_processes
+
+  # dashboards
+  ## rows
+  - name: instance_fetched_rows_rate
+    exp: pg_stat_database_tup_fetched.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  - name: instance_deleted_rows_rate
+    exp: pg_stat_database_tup_deleted.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  - name: instance_inserted_rows_rate
+    exp: pg_stat_database_tup_inserted.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  - name: instance_updated_rows_rate
+    exp: pg_stat_database_tup_updated.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  - name: instance_returned_rows_rate
+    exp: pg_stat_database_tup_returned.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  ## locks
+  - name: instance_locks_count
+    exp: pg_locks_count.tag({tags -> tags.mode = tags.datname + ":" + tags.mode}).sum(['mode','host_name','service_instance_id'])
+
+  ## sessions
+  - name: instance_active_sessions
+    exp: pg_stat_activity_count.tagEqual('state','active').sum(['datname' , 'host_name','service_instance_id'])
+  - name: instance_idle_sessions
+    exp: pg_stat_activity_count.tagMatch('state','idle|idle in transaction|idle in transaction (aborted)').sum(['datname','host_name','service_instance_id'])
+
+  ## transactions
+  - name: instance_committed_transactions_rate
+    exp: pg_stat_database_xact_commit.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  - name: instance_rolled_back_transactions_rate
+    exp: pg_stat_database_xact_rollback.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+
+  ## cache and temporary file
+  - name: instance_cache_hit_rate
+    exp: (pg_stat_database_blks_hit*100 / (pg_stat_database_blks_read + pg_stat_database_blks_hit)).sum(['datname','host_name','service_instance_id'])
+  - name: instance_temporary_files_rate
+    exp: pg_stat_database_temp_bytes.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+
+  ## checkpoint
+  - name: instance_checkpoint_write_time_rate
+    exp: pg_stat_bgwriter_checkpoint_write_time_total.rate('PT1M')
+  - name: instance_checkpoint_sync_time_rate
+    exp: pg_stat_bgwriter_checkpoint_sync_time_total.rate('PT1M')
+  - name: instance_checkpoint_req_rate
+    exp: pg_stat_bgwriter_checkpoints_req_total.rate('PT1M')
+  - name: instance_checkpoints_timed_rate
+    exp: pg_stat_bgwriter_checkpoints_timed_total.rate('PT1M')
+
+  ## conflicts and deadlocks
+  - name: instance_conflicts_rate
+    exp: pg_stat_database_conflicts.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+  - name: instance_deadlocks_rate
+    exp: pg_stat_database_deadlocks.sum(['datname','host_name','service_instance_id']).rate('PT1M')
+
+  ## buffers
+  - name: instance_buffers_checkpoint
+    exp: pg_stat_bgwriter_buffers_checkpoint.rate('PT1M')
+  - name: instance_buffers_clean
+    exp: pg_stat_bgwriter_buffers_clean.rate('PT1M')
+  - name: instance_buffers_backend_fsync
+    exp: pg_stat_bgwriter_buffers_backend_fsync.rate('PT1M')
+  - name: instance_buffers_alloc
+    exp: pg_stat_bgwriter_buffers_alloc.rate('PT1M')
+  - name: instance_buffers_backend
+    exp: pg_stat_bgwriter_buffers_backend.rate('PT1M')
diff --git a/oap-server/server-starter/src/main/resources/otel-rules/postgresql.yaml b/oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-service.yaml
similarity index 67%
rename from oap-server/server-starter/src/main/resources/otel-rules/postgresql.yaml
rename to oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-service.yaml
index d65707d5ae4f..1dc9e3e388fb 100644
--- a/oap-server/server-starter/src/main/resources/otel-rules/postgresql.yaml
+++ b/oap-server/server-starter/src/main/resources/otel-rules/postgresql/postgresql-service.yaml
@@ -32,59 +32,39 @@ filter: "{ tags -> tags.job_name == 'postgresql-monitoring' }" # The OpenTelemet
 expSuffix:  tag({tags -> tags.host_name = 'postgresql::' + tags.host_name}).service(['host_name'] , Layer.POSTGRESQL)
 metricPrefix: meter_pg
 metricsRules:
-  # postgresql configurations
-  - name: shared_buffers
-    exp: pg_settings_shared_buffers_bytes
-  - name: effective_cache
-    exp: pg_settings_effective_cache_size_bytes
-  - name: maintenance_work_mem
-    exp: pg_settings_maintenance_work_mem_bytes
-  - name: work_mem
-    exp: pg_settings_work_mem_bytes
-  - name: seq_page_cost
-    exp: pg_settings_seq_page_cost
-  - name: random_page_cost
-    exp: pg_settings_random_page_cost
-  - name: max_wal_size
-    exp: pg_settings_max_wal_size_bytes
-  - name: max_parallel_workers
-    exp: pg_settings_max_parallel_workers
-  - name: max_worker_processes
-    exp: pg_settings_max_worker_processes
-
   # dashboards
   ## rows
   - name: fetched_rows_rate
-    exp: pg_stat_database_tup_fetched.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_tup_fetched.sum(['service_instance_id','host_name']).rate('PT1M')
   - name: deleted_rows_rate
-    exp: pg_stat_database_tup_deleted.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_tup_deleted.sum(['service_instance_id','host_name']).rate('PT1M')
   - name: inserted_rows_rate
-    exp: pg_stat_database_tup_inserted.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_tup_inserted.sum(['service_instance_id','host_name']).rate('PT1M')
   - name: updated_rows_rate
-    exp: pg_stat_database_tup_updated.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_tup_updated.sum(['service_instance_id','host_name']).rate('PT1M')
   - name: returned_rows_rate
-    exp: pg_stat_database_tup_returned.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_tup_returned.sum(['service_instance_id','host_name']).rate('PT1M')
   ## locks
   - name: locks_count
-    exp: pg_locks_count.tag({tags -> tags.mode = tags.datname + ":" + tags.mode}).sum(['mode','host_name'])
+    exp: pg_locks_count.tag({tags -> tags.mode = tags.datname + ":" + tags.mode}).sum(['service_instance_id','host_name'])
 
   ## sessions
   - name: active_sessions
-    exp: pg_stat_activity_count.tagEqual('state','active').sum(['datname' , 'host_name'])
+    exp: pg_stat_activity_count.tagEqual('state','active').sum(['service_instance_id' , 'host_name'])
   - name: idle_sessions
-    exp: pg_stat_activity_count.tagMatch('state','idle|idle in transaction|idle in transaction (aborted)').sum(['datname' , 'host_name'])
+    exp: pg_stat_activity_count.tagMatch('state','idle|idle in transaction|idle in transaction (aborted)').sum(['service_instance_id' , 'host_name'])
 
   ## transactions
   - name: committed_transactions_rate
-    exp: pg_stat_database_xact_commit.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_xact_commit.sum(['service_instance_id','host_name']).rate('PT1M')
   - name: rolled_back_transactions_rate
-    exp: pg_stat_database_xact_rollback.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_xact_rollback.sum(['service_instance_id','host_name']).rate('PT1M')
 
   ## cache and temporary file
   - name: cache_hit_rate
-    exp: (pg_stat_database_blks_hit*100 / (pg_stat_database_blks_read + pg_stat_database_blks_hit)).sum(['datname','host_name'])
+    exp: (pg_stat_database_blks_hit*100 / (pg_stat_database_blks_read + pg_stat_database_blks_hit)).sum(['service_instance_id','host_name'])
   - name: temporary_files_rate
-    exp: pg_stat_database_temp_bytes.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_temp_bytes.sum(['service_instance_id','host_name']).rate('PT1M')
 
   ## checkpoint
   - name: checkpoint_write_time_rate
@@ -98,9 +78,9 @@ metricsRules:
 
   ## conflicts and deadlocks
   - name: conflicts_rate
-    exp: pg_stat_database_conflicts.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_conflicts.sum(['service_instance_id','host_name']).rate('PT1M')
   - name: deadlocks_rate
-    exp: pg_stat_database_deadlocks.sum(['datname','host_name']).rate('PT1M')
+    exp: pg_stat_database_deadlocks.sum(['service_instance_id','host_name']).rate('PT1M')
 
   ## buffers
   - name: buffers_checkpoint
diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-instance.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-instance.json
new file mode 100644
index 000000000000..bd00a53fcd31
--- /dev/null
+++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-instance.json
@@ -0,0 +1,320 @@
+/**
+ * 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.
+ */
+
+[
+  {
+    "id":"mysql-instance                                                                                                            ",
+    "configuration":{
+      "children":[
+        {
+          "x":0,
+          "y":0,
+          "w":6,
+          "h":9,
+          "i":"0",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValue"
+          ],
+          "metrics":[
+            "meter_mysql_instance_uptime"
+          ],
+          "graph":{
+            "type":"Card",
+            "fontSize":40,
+            "textAlign":"center",
+            "showUnit":true
+          },
+          "metricConfig":[
+            {
+              "calculation":"secondToDay"
+            }
+          ],
+          "widget":{
+            "title":"MySQL Uptime (day)"
+          }
+        },
+        {
+          "x":0,
+          "y":9,
+          "w":6,
+          "h":10,
+          "i":"1",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_qps"
+          ],
+          "graph":{
+            "type":"Line",
+            "step":false,
+            "smooth":false,
+            "showSymbol":false,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Current QPS"
+          }
+        },
+        {
+          "x":12,
+          "y":0,
+          "w":6,
+          "h":9,
+          "i":"2",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValue"
+          ],
+          "metrics":[
+            "meter_mysql_instance_innodb_buffer_pool_size"
+          ],
+          "graph":{
+            "type":"Card",
+            "fontSize":40,
+            "textAlign":"center",
+            "showUnit":true
+          },
+          "metricConfig":[
+            {
+              "calculation":"byteToMB"
+            }
+          ],
+          "widget":{
+            "title":"Innodb Buffer Pool Size (MB)"
+          }
+        },
+        {
+          "x":6,
+          "y":0,
+          "w":6,
+          "h":9,
+          "i":"3",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValue"
+          ],
+          "metrics":[
+            "meter_mysql_instance_max_connections"
+          ],
+          "graph":{
+            "type":"Card",
+            "fontSize":40,
+            "textAlign":"center",
+            "showUnit":true
+          },
+          "widget":{
+            "title":"Max Connections"
+          }
+        },
+        {
+          "x":18,
+          "y":0,
+          "w":6,
+          "h":9,
+          "i":"4",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValue"
+          ],
+          "metrics":[
+            "meter_mysql_instance_thread_cache_size"
+          ],
+          "graph":{
+            "type":"Card",
+            "fontSize":40,
+            "textAlign":"center",
+            "showUnit":true
+          },
+          "widget":{
+            "title":"Thread Cache Size"
+          }
+        },
+        {
+          "x":6,
+          "y":9,
+          "w":6,
+          "h":10,
+          "i":"5",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_tps"
+          ],
+          "graph":{
+            "type":"Line",
+            "step":false,
+            "smooth":false,
+            "showSymbol":false,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Current TPS"
+          }
+        },
+        {
+          "x":12,
+          "y":9,
+          "w":6,
+          "h":10,
+          "i":"6",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues",
+            "readMetricsValues",
+            "readMetricsValues",
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_commands_insert_rate",
+            "meter_mysql_instance_commands_select_rate",
+            "meter_mysql_instance_commands_delete_rate",
+            "meter_mysql_instance_commands_update_rate"
+          ],
+          "graph":{
+            "type":"Area",
+            "opacity":0.4,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Commands Trend (rows per second)"
+          }
+        },
+        {
+          "x":6,
+          "y":19,
+          "w":6,
+          "h":10,
+          "i":"7",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues",
+            "readMetricsValues",
+            "readMetricsValues",
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_threads_cached",
+            "meter_mysql_instance_threads_running",
+            "meter_mysql_instance_threads_created",
+            "meter_mysql_instance_threads_connected"
+          ],
+          "graph":{
+            "type":"Area",
+            "opacity":0.4,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Threads"
+          }
+        },
+        {
+          "x":0,
+          "y":19,
+          "w":6,
+          "h":10,
+          "i":"8",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues",
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_connects_available",
+            "meter_mysql_instance_connects_aborted"
+          ],
+          "graph":{
+            "type":"Line",
+            "step":false,
+            "smooth":false,
+            "showSymbol":false,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Connects"
+          }
+        },
+        {
+          "x":18,
+          "y":9,
+          "w":6,
+          "h":10,
+          "i":"10",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_slow_queries_rate"
+          ],
+          "graph":{
+            "type":"Line",
+            "step":false,
+            "smooth":false,
+            "showSymbol":false,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Slow Queries Trend (queries per second)"
+          }
+        },
+        {
+          "x":12,
+          "y":19,
+          "w":6,
+          "h":10,
+          "i":"11",
+          "type":"Widget",
+          "metricTypes":[
+            "readMetricsValues",
+            "readMetricsValues"
+          ],
+          "metrics":[
+            "meter_mysql_instance_connection_errors_internal",
+            "meter_mysql_instance_connection_errors_max_connections"
+          ],
+          "graph":{
+            "type":"Line",
+            "step":false,
+            "smooth":false,
+            "showSymbol":false,
+            "showXAxis":true,
+            "showYAxis":true
+          },
+          "widget":{
+            "title":"Connection Errors"
+          }
+        }
+      ],
+      "layer":"MYSQL",
+      "entity":"ServiceInstance",
+      "name":"MySQL-Instance",
+      "id":"mysql-instance",
+      "isRoot":false
+    }
+  }
+]
\ No newline at end of file
diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-root.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-root.json
index 5aab25ae3e5e..3f353fa64ac7 100644
--- a/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-root.json
+++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-root.json
@@ -17,7 +17,7 @@
 
 [
    {
-      "id":"b6e3763c-882d-417f-8556-3cf0187cb8db",
+      "id":"mysql-root",
       "configuration":{
          "children":[
             {
@@ -53,7 +53,7 @@
                }
             }
          ],
-         "id":"b6e3763c-882d-417f-8556-3cf0187cb8db",
+         "id":"mysql-root",
          "layer":"MYSQL",
          "entity":"All",
          "name":"MySQL-Root",
diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-service.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-service.json
index e9e23640870d..b0967fc4965a 100644
--- a/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-service.json
+++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/mysql/mysql-service.json
@@ -17,7 +17,7 @@
 
 [
    {
-      "id":"2ca19857-dcdb-491a-9739-d7ab79beb60b",
+      "id":"mysql-service",
       "configuration":{
          "children":[
             {
@@ -35,35 +35,7 @@
                            "x":0,
                            "y":0,
                            "w":6,
-                           "h":9,
-                           "i":"0",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_mysql_uptime"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"secondToDay"
-                              }
-                           ],
-                           "widget":{
-                              "title":"MySQL Uptime (day)"
-                           }
-                        },
-                        {
-                           "x":0,
-                           "y":9,
-                           "w":6,
-                           "h":10,
+                           "h":13,
                            "i":"1",
                            "type":"Widget",
                            "metricTypes":[
@@ -84,85 +56,11 @@
                               "title":"Current QPS"
                            }
                         },
-                        {
-                           "x":12,
-                           "y":0,
-                           "w":6,
-                           "h":9,
-                           "i":"2",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_mysql_innodb_buffer_pool_size"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"byteToMB"
-                              }
-                           ],
-                           "widget":{
-                              "title":"Innodb Buffer Pool Size (MB)"
-                           }
-                        },
                         {
                            "x":6,
                            "y":0,
                            "w":6,
-                           "h":9,
-                           "i":"3",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_mysql_max_connections"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Max Connections"
-                           }
-                        },
-                        {
-                           "x":18,
-                           "y":0,
-                           "w":6,
-                           "h":9,
-                           "i":"4",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_mysql_thread_cache_size"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Thread Cache Size"
-                           }
-                        },
-                        {
-                           "x":6,
-                           "y":9,
-                           "w":6,
-                           "h":10,
+                           "h":13,
                            "i":"5",
                            "type":"Widget",
                            "metricTypes":[
@@ -185,9 +83,9 @@
                         },
                         {
                            "x":12,
-                           "y":9,
+                           "y":0,
                            "w":6,
-                           "h":10,
+                           "h":13,
                            "i":"6",
                            "type":"Widget",
                            "metricTypes":[
@@ -214,9 +112,9 @@
                         },
                         {
                            "x":6,
-                           "y":19,
+                           "y":13,
                            "w":6,
-                           "h":10,
+                           "h":14,
                            "i":"7",
                            "type":"Widget",
                            "metricTypes":[
@@ -243,9 +141,9 @@
                         },
                         {
                            "x":0,
-                           "y":19,
+                           "y":13,
                            "w":6,
-                           "h":10,
+                           "h":13,
                            "i":"8",
                            "type":"Widget",
                            "metricTypes":[
@@ -270,9 +168,9 @@
                         },
                         {
                            "x":18,
-                           "y":9,
+                           "y":0,
                            "w":6,
-                           "h":10,
+                           "h":13,
                            "i":"10",
                            "type":"Widget",
                            "metricTypes":[
@@ -295,9 +193,9 @@
                         },
                         {
                            "x":12,
-                           "y":19,
+                           "y":13,
                            "w":6,
-                           "h":10,
+                           "h":14,
                            "i":"11",
                            "type":"Widget",
                            "metricTypes":[
@@ -352,6 +250,36 @@
                            ]
                         }
                      ]
+                  },
+                  {
+                     "name":"Instances",
+                     "children":[
+                        {
+                           "x":0,
+                           "y":0,
+                           "w":24,
+                           "h":29,
+                           "i":"0",
+                           "type":"Widget",
+                           "graph":{
+                              "type":"InstanceList",
+                              "dashboardName":"MySQL-Instance",
+                              "fontSize":12
+                           },
+                           "metrics":[
+                              "meter_mysql_instance_uptime"
+                           ],
+                           "metricTypes":[
+                              "readMetricsValue",
+                              ""
+                           ],
+                           "metricConfig":[
+                              {
+                                 "calculation":"secondToDay"
+                              }
+                           ]
+                        }
+                     ]
                   }
                ]
             }
@@ -359,8 +287,8 @@
          "layer":"MYSQL",
          "entity":"Service",
          "name":"MySQL-Service",
-         "id":"2ca19857-dcdb-491a-9739-d7ab79beb60b",
+         "id":"mysql-service",
          "isRoot":false
       }
    }
-]
+]
\ No newline at end of file
diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-instance.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-instance.json
new file mode 100644
index 000000000000..2f702fc838d0
--- /dev/null
+++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-instance.json
@@ -0,0 +1,700 @@
+/**
+ * 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.
+ */
+
+[
+   {
+      "id":"postgresql-instance",
+      "configuration":{
+         "children":[
+            {
+               "x":0,
+               "y":0,
+               "w":4,
+               "h":6,
+               "i":"0",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_shared_buffers"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "metricConfig":[
+                  {
+                     "calculation":"byteToMB"
+                  }
+               ],
+               "widget":{
+                  "title":"Shared Buffers (MB)"
+               }
+            },
+            {
+               "x":4,
+               "y":0,
+               "w":5,
+               "h":6,
+               "i":"1",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_effective_cache"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "metricConfig":[
+                  {
+                     "calculation":"byteToGB"
+                  }
+               ],
+               "widget":{
+                  "title":"Effective Cache (GB)"
+               }
+            },
+            {
+               "x":4,
+               "y":6,
+               "w":5,
+               "h":6,
+               "i":"2",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_maintenance_work_mem"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "widget":{
+                  "title":"Maintenance Work Mem (MB)"
+               },
+               "metricConfig":[
+                  {
+                     "calculation":"byteToMB"
+                  }
+               ]
+            },
+            {
+               "x":14,
+               "y":6,
+               "w":5,
+               "h":6,
+               "i":"3",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_work_mem"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "metricConfig":[
+                  {
+                     "calculation":"byteToMB"
+                  }
+               ],
+               "widget":{
+                  "title":"Work Mem (MB)"
+               }
+            },
+            {
+               "x":9,
+               "y":0,
+               "w":5,
+               "h":6,
+               "i":"4",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_seq_page_cost"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "widget":{
+                  "title":"Seq Page Cost"
+               }
+            },
+            {
+               "x":14,
+               "y":0,
+               "w":5,
+               "h":6,
+               "i":"5",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_random_page_cost"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "widget":{
+                  "title":"Random Page Cost"
+               }
+            },
+            {
+               "x":0,
+               "y":6,
+               "w":4,
+               "h":6,
+               "i":"6",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_max_wal_size"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "widget":{
+                  "title":"Max WAL Size (GB)"
+               },
+               "metricConfig":[
+                  {
+                     "calculation":"byteToGB"
+                  }
+               ]
+            },
+            {
+               "x":9,
+               "y":6,
+               "w":5,
+               "h":6,
+               "i":"7",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_max_parallel_workers"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "widget":{
+                  "title":"Max Parallel Workers"
+               }
+            },
+            {
+               "x":19,
+               "y":0,
+               "w":5,
+               "h":6,
+               "i":"8",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValue"
+               ],
+               "metrics":[
+                  "meter_pg_instance_max_worker_processes"
+               ],
+               "graph":{
+                  "type":"Card",
+                  "fontSize":40,
+                  "textAlign":"center",
+                  "showUnit":true
+               },
+               "widget":{
+                  "title":"Max Worker Processes"
+               }
+            },
+            {
+               "x":0,
+               "y":12,
+               "w":6,
+               "h":10,
+               "i":"9",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_fetched_rows_rate"
+               ],
+               "graph":{
+                  "type":"Area",
+                  "opacity":0.4,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Fetched Rows Trend (rows per second)"
+               },
+               "value":"9",
+               "label":"9"
+            },
+            {
+               "x":6,
+               "y":12,
+               "w":6,
+               "h":10,
+               "i":"10",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_inserted_rows_rate"
+               ],
+               "graph":{
+                  "type":"Area",
+                  "opacity":0.4,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Inserted Rows Trend (rows per second)"
+               },
+               "value":"10",
+               "label":"10"
+            },
+            {
+               "x":6,
+               "y":32,
+               "w":6,
+               "h":10,
+               "i":"11",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValues",
+                  "readMetricsValues",
+                  "readMetricsValues",
+                  "readMetricsValues",
+                  "readMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_buffers_clean",
+                  "meter_pg_instance_buffers_backend",
+                  "meter_pg_instance_buffers_checkpoint",
+                  "meter_pg_instance_buffers_backend_fsync",
+                  "meter_pg_instance_buffers_alloc"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Buffers Trend (per second)"
+               },
+               "value":"11",
+               "label":"11"
+            },
+            {
+               "x":12,
+               "y":12,
+               "w":6,
+               "h":10,
+               "i":"12",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_updated_rows_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Updated Rows Trend (rows per second)"
+               },
+               "value":"12",
+               "label":"12"
+            },
+            {
+               "x":18,
+               "y":12,
+               "w":6,
+               "h":10,
+               "i":"13",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_deleted_rows_rate"
+               ],
+               "graph":{
+                  "type":"Area",
+                  "opacity":0.4,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Deleted Rows Trend (rows per second)"
+               },
+               "value":"13",
+               "label":"13"
+            },
+            {
+               "x":0,
+               "y":22,
+               "w":6,
+               "h":10,
+               "i":"14",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_returned_rows_rate"
+               ],
+               "graph":{
+                  "type":"Area",
+                  "opacity":0.4,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Returned Rows Trend (rows per second)"
+               },
+               "value":"14",
+               "label":"14"
+            },
+            {
+               "x":6,
+               "y":42,
+               "w":6,
+               "h":10,
+               "i":"15",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_temporary_files_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "value":"15",
+               "label":"15",
+               "widget":{
+                  "title":"Temporary Files Trend (per second)"
+               }
+            },
+            {
+               "x":12,
+               "y":22,
+               "w":6,
+               "h":10,
+               "i":"16",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_committed_transactions_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Committed Transactions Trend (per second)"
+               },
+               "value":"16",
+               "label":"16"
+            },
+            {
+               "x":6,
+               "y":22,
+               "w":6,
+               "h":10,
+               "i":"17",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_rolled_back_transactions_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Rolled Back Transactions Trend (per second)"
+               },
+               "value":"17",
+               "label":"17"
+            },
+            {
+               "x":0,
+               "y":32,
+               "w":6,
+               "h":10,
+               "i":"18",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_cache_hit_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Cache Hit Rate (%)"
+               },
+               "value":"18",
+               "label":"18"
+            },
+            {
+               "x":12,
+               "y":42,
+               "w":6,
+               "h":10,
+               "i":"19",
+               "type":"Widget",
+               "metricTypes":[
+                  "readMetricsValues",
+                  "readMetricsValues",
+                  "readMetricsValues",
+                  "readMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_checkpoint_sync_time_rate",
+                  "meter_pg_instance_checkpoints_timed_rate",
+                  "meter_pg_instance_checkpoint_req_rate",
+                  "meter_pg_instance_checkpoint_write_time_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Checkpoint Stat Trend (per second)"
+               },
+               "value":"19",
+               "label":"19"
+            },
+            {
+               "x":18,
+               "y":22,
+               "w":6,
+               "h":10,
+               "i":"20",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_conflicts_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Conflicts Trend (per second)"
+               },
+               "value":"20",
+               "label":"20"
+            },
+            {
+               "x":0,
+               "y":42,
+               "w":6,
+               "h":10,
+               "i":"21",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_deadlocks_rate"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Deadlocks Trend (per second)"
+               },
+               "value":"21",
+               "label":"21"
+            },
+            {
+               "x":12,
+               "y":32,
+               "w":6,
+               "h":10,
+               "i":"22",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_active_sessions"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Active Sessions"
+               },
+               "value":"22",
+               "label":"22"
+            },
+            {
+               "x":18,
+               "y":42,
+               "w":6,
+               "h":10,
+               "i":"23",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_locks_count"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Locks"
+               },
+               "value":"23",
+               "label":"23"
+            },
+            {
+               "x":18,
+               "y":32,
+               "w":6,
+               "h":10,
+               "i":"24",
+               "type":"Widget",
+               "metricTypes":[
+                  "readLabeledMetricsValues"
+               ],
+               "metrics":[
+                  "meter_pg_instance_idle_sessions"
+               ],
+               "graph":{
+                  "type":"Line",
+                  "step":false,
+                  "smooth":false,
+                  "showSymbol":false,
+                  "showXAxis":true,
+                  "showYAxis":true
+               },
+               "widget":{
+                  "title":"Idle Sessions"
+               },
+               "value":"24",
+               "label":"24"
+            }
+         ],
+         "layer":"POSTGRESQL",
+         "entity":"ServiceInstance",
+         "name":"PostgreSQL-Instance",
+         "id":"postgresql-instance"
+      }
+   }
+]
diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-root.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-root.json
index 62914852b3de..3b969bf0113b 100644
--- a/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-root.json
+++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-root.json
@@ -17,7 +17,7 @@
 
 [
    {
-      "id":"90ec4ee8-3df2-4bd9-bcb1-2d50cbe49634",
+      "id":"postgresql-root",
       "configuration":{
          "children":[
             {
@@ -56,7 +56,7 @@
          "layer":"POSTGRESQL",
          "entity":"All",
          "name":"PostgreSQL-Root",
-         "id":"90ec4ee8-3df2-4bd9-bcb1-2d50cbe49634",
+         "id":"postgresql-root",
          "isRoot":true
       }
    }
diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-service.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-service.json
index 85c804a3f87c..13fd757be54e 100644
--- a/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-service.json
+++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/postgresql/postgresql-service.json
@@ -17,14 +17,14 @@
 
 [
    {
-      "id":"7da9d2e6-7c10-4ab4-ba86-fd73889608ff",
+      "id":"postgresql-service",
       "configuration":{
          "children":[
             {
                "x":0,
                "y":0,
                "w":24,
-               "h":33,
+               "h":37,
                "i":"0",
                "type":"Tab",
                "children":[
@@ -34,238 +34,6 @@
                         {
                            "x":0,
                            "y":0,
-                           "w":4,
-                           "h":6,
-                           "i":"0",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_shared_buffers"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"byteToMB"
-                              }
-                           ],
-                           "widget":{
-                              "title":"Shared Buffers (MB)"
-                           }
-                        },
-                        {
-                           "x":4,
-                           "y":0,
-                           "w":5,
-                           "h":6,
-                           "i":"1",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_effective_cache"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"byteToGB"
-                              }
-                           ],
-                           "widget":{
-                              "title":"Effective Cache (GB)"
-                           }
-                        },
-                        {
-                           "x":4,
-                           "y":6,
-                           "w":5,
-                           "h":6,
-                           "i":"2",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_maintenance_work_mem"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Maintenance Work Mem (MB)"
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"byteToMB"
-                              }
-                           ]
-                        },
-                        {
-                           "x":14,
-                           "y":6,
-                           "w":5,
-                           "h":6,
-                           "i":"3",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_work_mem"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"byteToMB"
-                              }
-                           ],
-                           "widget":{
-                              "title":"Work Mem (MB)"
-                           }
-                        },
-                        {
-                           "x":9,
-                           "y":0,
-                           "w":5,
-                           "h":6,
-                           "i":"4",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_seq_page_cost"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Seq Page Cost"
-                           }
-                        },
-                        {
-                           "x":14,
-                           "y":0,
-                           "w":5,
-                           "h":6,
-                           "i":"5",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_random_page_cost"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Random Page Cost"
-                           }
-                        },
-                        {
-                           "x":0,
-                           "y":6,
-                           "w":4,
-                           "h":6,
-                           "i":"6",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_max_wal_size"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Max WAL Size (GB)"
-                           },
-                           "metricConfig":[
-                              {
-                                 "calculation":"byteToGB"
-                              }
-                           ]
-                        },
-                        {
-                           "x":9,
-                           "y":6,
-                           "w":5,
-                           "h":6,
-                           "i":"7",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_max_parallel_workers"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Max Parallel Workers"
-                           }
-                        },
-                        {
-                           "x":19,
-                           "y":0,
-                           "w":5,
-                           "h":6,
-                           "i":"8",
-                           "type":"Widget",
-                           "metricTypes":[
-                              "readMetricsValue"
-                           ],
-                           "metrics":[
-                              "meter_pg_max_worker_processes"
-                           ],
-                           "graph":{
-                              "type":"Card",
-                              "fontSize":40,
-                              "textAlign":"center",
-                              "showUnit":true
-                           },
-                           "widget":{
-                              "title":"Max Worker Processes"
-                           }
-                        },
-                        {
-                           "x":0,
-                           "y":12,
                            "w":6,
                            "h":10,
                            "i":"9",
@@ -284,13 +52,11 @@
                            },
                            "widget":{
                               "title":"Fetched Rows Trend (rows per second)"
-                           },
-                           "value":"9",
-                           "label":"9"
+                           }
                         },
                         {
                            "x":6,
-                           "y":12,
+                           "y":0,
                            "w":6,
                            "h":10,
                            "i":"10",
@@ -309,13 +75,11 @@
                            },
                            "widget":{
                               "title":"Inserted Rows Trend (rows per second)"
-                           },
-                           "value":"10",
-                           "label":"10"
+                           }
                         },
                         {
                            "x":6,
-                           "y":32,
+                           "y":20,
                            "w":6,
                            "h":10,
                            "i":"11",
@@ -344,13 +108,11 @@
                            },
                            "widget":{
                               "title":"Buffers Trend (per second)"
-                           },
-                           "value":"11",
-                           "label":"11"
+                           }
                         },
                         {
                            "x":12,
-                           "y":12,
+                           "y":0,
                            "w":6,
                            "h":10,
                            "i":"12",
@@ -371,13 +133,11 @@
                            },
                            "widget":{
                               "title":"Updated Rows Trend (rows per second)"
-                           },
-                           "value":"12",
-                           "label":"12"
+                           }
                         },
                         {
                            "x":18,
-                           "y":12,
+                           "y":0,
                            "w":6,
                            "h":10,
                            "i":"13",
@@ -396,13 +156,11 @@
                            },
                            "widget":{
                               "title":"Deleted Rows Trend (rows per second)"
-                           },
-                           "value":"13",
-                           "label":"13"
+                           }
                         },
                         {
                            "x":0,
-                           "y":22,
+                           "y":10,
                            "w":6,
                            "h":10,
                            "i":"14",
@@ -421,13 +179,11 @@
                            },
                            "widget":{
                               "title":"Returned Rows Trend (rows per second)"
-                           },
-                           "value":"14",
-                           "label":"14"
+                           }
                         },
                         {
                            "x":6,
-                           "y":42,
+                           "y":30,
                            "w":6,
                            "h":10,
                            "i":"15",
@@ -446,15 +202,13 @@
                               "showXAxis":true,
                               "showYAxis":true
                            },
-                           "value":"15",
-                           "label":"15",
                            "widget":{
                               "title":"Temporary Files Trend (per second)"
                            }
                         },
                         {
                            "x":12,
-                           "y":22,
+                           "y":10,
                            "w":6,
                            "h":10,
                            "i":"16",
@@ -475,13 +229,11 @@
                            },
                            "widget":{
                               "title":"Committed Transactions Trend (per second)"
-                           },
-                           "value":"16",
-                           "label":"16"
+                           }
                         },
                         {
                            "x":6,
-                           "y":22,
+                           "y":10,
                            "w":6,
                            "h":10,
                            "i":"17",
@@ -502,13 +254,11 @@
                            },
                            "widget":{
                               "title":"Rolled Back Transactions Trend (per second)"
-                           },
-                           "value":"17",
-                           "label":"17"
+                           }
                         },
                         {
                            "x":0,
-                           "y":32,
+                           "y":20,
                            "w":6,
                            "h":10,
                            "i":"18",
@@ -529,13 +279,11 @@
                            },
                            "widget":{
                               "title":"Cache Hit Rate (%)"
-                           },
-                           "value":"18",
-                           "label":"18"
+                           }
                         },
                         {
                            "x":12,
-                           "y":42,
+                           "y":30,
                            "w":6,
                            "h":10,
                            "i":"19",
@@ -562,13 +310,11 @@
                            },
                            "widget":{
                               "title":"Checkpoint Stat Trend (per second)"
-                           },
-                           "value":"19",
-                           "label":"19"
+                           }
                         },
                         {
                            "x":18,
-                           "y":22,
+                           "y":10,
                            "w":6,
                            "h":10,
                            "i":"20",
@@ -589,13 +335,11 @@
                            },
                            "widget":{
                               "title":"Conflicts Trend (per second)"
-                           },
-                           "value":"20",
-                           "label":"20"
+                           }
                         },
                         {
                            "x":0,
-                           "y":42,
+                           "y":30,
                            "w":6,
                            "h":10,
                            "i":"21",
@@ -616,13 +360,11 @@
                            },
                            "widget":{
                               "title":"Deadlocks Trend (per second)"
-                           },
-                           "value":"21",
-                           "label":"21"
+                           }
                         },
                         {
                            "x":12,
-                           "y":32,
+                           "y":20,
                            "w":6,
                            "h":10,
                            "i":"22",
@@ -643,13 +385,11 @@
                            },
                            "widget":{
                               "title":"Active Sessions"
-                           },
-                           "value":"22",
-                           "label":"22"
+                           }
                         },
                         {
                            "x":18,
-                           "y":42,
+                           "y":30,
                            "w":6,
                            "h":10,
                            "i":"23",
@@ -670,13 +410,11 @@
                            },
                            "widget":{
                               "title":"Locks"
-                           },
-                           "value":"23",
-                           "label":"23"
+                           }
                         },
                         {
                            "x":18,
-                           "y":32,
+                           "y":20,
                            "w":6,
                            "h":10,
                            "i":"24",
@@ -697,9 +435,7 @@
                            },
                            "widget":{
                               "title":"Idle Sessions"
-                           },
-                           "value":"24",
-                           "label":"24"
+                           }
                         }
                      ]
                   },
@@ -733,6 +469,58 @@
                            ]
                         }
                      ]
+                  },
+                  {
+                     "name":"Instances",
+                     "children":[
+                        {
+                           "x":0,
+                           "y":0,
+                           "w":24,
+                           "h":32,
+                           "i":"0",
+                           "type":"Widget",
+                           "metricTypes":[
+                              "readMetricsValue",
+                              "readMetricsValue",
+                              "readMetricsValue",
+                              "readMetricsValue",
+                              "readMetricsValue"
+                           ],
+                           "metrics":[
+                              "meter_pg_instance_shared_buffers",
+                              "meter_pg_instance_effective_cache",
+                              "meter_pg_instance_seq_page_cost",
+                              "meter_pg_instance_random_page_cost",
+                              "meter_pg_instance_work_mem"
+                           ],
+                           "graph":{
+                              "type":"InstanceList",
+                              "dashboardName":"PostgreSQL-Instance",
+                              "fontSize":12
+                           },
+                           "metricConfig":[
+                              {
+                                 "calculation":"byteToMB",
+                                 "label":"Shared Buffers (MB)"
+                              },
+                              {
+                                 "label":"Effective Cache (GB)",
+                                 "calculation":"byteToGB"
+                              },
+                              {
+                                 "label":"Seq Page Cost"
+                              },
+                              {
+                                 "label":"Random Page Cost"
+                              },
+                              {
+                                 "label":"Work Mem (MB)",
+                                 "calculation":"byteToMB"
+                              }
+                           ]
+                        }
+                     ]
                   }
                ]
             }
@@ -740,7 +528,7 @@
          "layer":"POSTGRESQL",
          "entity":"Service",
          "name":"PostgreSQL-Service",
-         "id":"7da9d2e6-7c10-4ab4-ba86-fd73889608ff"
+         "id":"postgresql-service"
       }
    }
 ]


Test patch:
diff --git a/test/e2e-v2/cases/mysql/mysql-cases.yaml b/test/e2e-v2/cases/mysql/mysql-cases.yaml
index 360d34957172..bb59d32dcda2 100644
--- a/test/e2e-v2/cases/mysql/mysql-cases.yaml
+++ b/test/e2e-v2/cases/mysql/mysql-cases.yaml
@@ -15,44 +15,69 @@
 
 # This file is used to show how to write configuration files and can be used to test.
 
-  cases:
-    # service list
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
-      expected:  expected/service.yml
-    # metrics
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_uptime --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_innodb_buffer_pool_size --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_max_connections --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_thread_cache_size --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-      
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_select_rate --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_insert_rate --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_update_rate --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_delete_rate --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_qps --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_tps --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
+cases:
+  # service list
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
+    expected:  expected/service.yml
+  # service metrics
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_select_rate --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_insert_rate --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_update_rate --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_commands_delete_rate --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_qps --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_tps --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
 
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_threads_connected --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_threads_created --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_threads_running --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_threads_connected --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_threads_created --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_threads_running --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
 
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_connects_aborted --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_connects_available --service-name=mysql::root[root] |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    # slow sql
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list --name=top_n_database_statement |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected:  expected/db-has-value.yml
\ No newline at end of file
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_connects_aborted --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_connects_available --service-name=mysql::root[root] |yq e 'to_entries' -
+    expected: expected/metrics-has-value.yml
+  # instance metrics
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_uptime --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_innodb_buffer_pool_size --service-name=mysql::root[root]  --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_max_connections --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_thread_cache_size --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_commands_select_rate --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_commands_insert_rate --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_commands_update_rate --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_commands_delete_rate --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_qps --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_tps --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_threads_connected --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_threads_created --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_threads_running --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_connects_aborted --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_mysql_instance_connects_available --service-name=mysql::root[root] --instance-name=mysql-service:9104 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  # slow sql
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list --name=top_n_database_statement |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected:  expected/db-has-value.yml
\ No newline at end of file
diff --git a/test/e2e-v2/cases/mysql/mysql-slowsql/docker-compose.yaml b/test/e2e-v2/cases/mysql/mysql-slowsql/docker-compose.yaml
index c2263301ffcd..a2ce1307666b 100644
--- a/test/e2e-v2/cases/mysql/mysql-slowsql/docker-compose.yaml
+++ b/test/e2e-v2/cases/mysql/mysql-slowsql/docker-compose.yaml
@@ -46,12 +46,25 @@ services:
       - "MYSQL_ROOT_PASSWORD=password"
       - "MYSQL_DATABASE=swtest"
     ports:
-      - 3306:3306
+      - 3306
     healthcheck:
       test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306"]
       interval: 5s
       timeout: 60s
       retries: 120
+  mysql_2: &mysql
+    image: mysql:8.0.13
+    networks:
+      - e2e
+    volumes:
+      - ../mysql-slowsql/my.cnf:/etc/my.cnf
+    environment:
+      - "MYSQL_ROOT_PASSWORD=password"
+      - "MYSQL_DATABASE=swtest"
+    ports:
+      - 3306
+  mysql_3:
+    <<: *mysql
   mysql-load:
     image: mysql:8.0.13
     depends_on:
@@ -65,6 +78,32 @@ services:
     command:
       - -c
       - "mysql -h mysql -uroot -ppassword < /docker/mock.sql"
+  mysql-load_2:
+    image: mysql:8.0.13
+    depends_on:
+      oap:
+        condition: service_healthy
+    networks:
+      - e2e
+    entrypoint: bash
+    volumes:
+      - ./mock.sql:/docker/mock.sql
+    command:
+      - -c
+      - "mysql -h mysql_2 -uroot -ppassword < /docker/mock.sql"
+  mysql-load_3:
+    image: mysql:8.0.13
+    depends_on:
+      oap:
+        condition: service_healthy
+    networks:
+      - e2e
+    entrypoint: bash
+    volumes:
+      - ./mock.sql:/docker/mock.sql
+    command:
+      - -c
+      - "mysql -h mysql_3 -uroot -ppassword < /docker/mock.sql"
   fluentbit:
     image: fluent/fluent-bit:1.9
     environment:
@@ -88,6 +127,26 @@ services:
       - e2e
     depends_on:
       - mysql
+  mysql-service_2:
+    image: prom/mysqld-exporter:v0.14.0
+    ports:
+      - 9104
+    environment:
+      - DATA_SOURCE_NAME=root:password@(mysql_2:3306)/
+    networks:
+      - e2e
+    depends_on:
+      - mysql_2
+  mysql-service_3:
+    image: prom/mysqld-exporter:v0.14.0
+    ports:
+      - 9104
+    environment:
+      - DATA_SOURCE_NAME=root:password@(mysql_3:3306)/
+    networks:
+      - e2e
+    depends_on:
+      - mysql_3
   otel-collector:
     image: otel/opentelemetry-collector:0.50.0
     networks:
diff --git a/test/e2e-v2/cases/mysql/prometheus-mysql-exporter/otel-collector-config.yaml b/test/e2e-v2/cases/mysql/prometheus-mysql-exporter/otel-collector-config.yaml
index c0b2f270be32..5a78af97fb35 100644
--- a/test/e2e-v2/cases/mysql/prometheus-mysql-exporter/otel-collector-config.yaml
+++ b/test/e2e-v2/cases/mysql/prometheus-mysql-exporter/otel-collector-config.yaml
@@ -20,7 +20,7 @@ receivers:
        - job_name: 'mysql-monitoring'
          scrape_interval: 5s
          static_configs:
-           - targets: ['mysql-service:9104']
+           - targets: ['mysql-service:9104', 'mysql-service_2:9104', 'mysql-service_3:9104']
              labels:
                host_name: root[root]
 processors:
diff --git a/test/e2e-v2/cases/postgresql/postgres-exporter/docker-compose.yml b/test/e2e-v2/cases/postgresql/postgres-exporter/docker-compose.yml
index e8853ab3edad..95f5c7e80b32 100644
--- a/test/e2e-v2/cases/postgresql/postgres-exporter/docker-compose.yml
+++ b/test/e2e-v2/cases/postgresql/postgres-exporter/docker-compose.yml
@@ -51,6 +51,26 @@ services:
       interval: 5s
       timeout: 60s
       retries: 120
+  postgres_2: &pgsql
+    image: postgres:14.1
+    environment:
+      - TZ=Asia/Shanghai
+      - POSTGRES_PASSWORD=123456
+      - POSTGRES_DB=skywalking
+    ports:
+      - 5432
+    command: postgres -c config_file=/etc/postgresql.conf
+    volumes:
+      - ./postgresql.conf:/etc/postgresql.conf
+    networks:
+      - e2e
+    healthcheck:
+      test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432" ]
+      interval: 5s
+      timeout: 60s
+      retries: 120
+  postgres_3:
+    <<: *pgsql
   postgres-load:
     image: postgres:14.1
     environment:
@@ -75,6 +95,26 @@ services:
       - DATA_SOURCE_NAME=postgresql://postgres:123456@postgres:5432/postgres?sslmode=disable
     networks:
       - e2e
+  postgres-exporter_2:
+    image: quay.io/prometheuscommunity/postgres-exporter:v0.11.0
+    depends_on:
+      - postgres
+    ports:
+      - 9187
+    environment:
+      - DATA_SOURCE_NAME=postgresql://postgres:123456@postgres_2:5432/postgres?sslmode=disable
+    networks:
+      - e2e
+  postgres-exporter_3:
+    image: quay.io/prometheuscommunity/postgres-exporter:v0.11.0
+    depends_on:
+      - postgres
+    ports:
+      - 9187
+    environment:
+      - DATA_SOURCE_NAME=postgresql://postgres:123456@postgres_3:5432/postgres?sslmode=disable
+    networks:
+      - e2e
   fluentbit:
     image: fluent/fluent-bit:1.9
     environment:
diff --git a/test/e2e-v2/cases/postgresql/postgres-exporter/otel-collector-config.yaml b/test/e2e-v2/cases/postgresql/postgres-exporter/otel-collector-config.yaml
index 10ee8dc00937..17502ae81900 100644
--- a/test/e2e-v2/cases/postgresql/postgres-exporter/otel-collector-config.yaml
+++ b/test/e2e-v2/cases/postgresql/postgres-exporter/otel-collector-config.yaml
@@ -20,7 +20,7 @@ receivers:
         - job_name: "postgresql-monitoring"
           scrape_interval: 5s
           static_configs:
-            - targets: ["postgres-exporter:9187"]
+            - targets: ["postgres-exporter:9187","postgres-exporter_2:9187","postgres-exporter_3:9187"]
               labels:
                 host_name: postgres:5432
 processors:
diff --git a/test/e2e-v2/cases/postgresql/postgresql-cases.yaml b/test/e2e-v2/cases/postgresql/postgresql-cases.yaml
index ca9147344ef9..18a5e25fe2b7 100644
--- a/test/e2e-v2/cases/postgresql/postgresql-cases.yaml
+++ b/test/e2e-v2/cases/postgresql/postgresql-cases.yaml
@@ -15,47 +15,63 @@
 
 # This file is used to show how to write configuration files and can be used to test.
 
-  cases:
-    # service list
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
-      expected:  expected/service.yml
-    # metrics
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_shared_buffers --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_effective_cache --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_maintenance_work_mem --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_work_mem --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-      
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_seq_page_cost --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_random_page_cost --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_max_wal_size --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_max_parallel_workers --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_max_worker_processes --service-name=postgresql::postgres:5432 |yq e 'to_entries' -
-      expected:  expected/metrics-has-value.yml
-  
+cases:
+  # service list
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
+    expected:  expected/service.yml
+  # service metrics
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_cache_hit_rate --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_fetched_rows_rate --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_inserted_rows_rate --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_updated_rows_rate --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_returned_rows_rate --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_deleted_rows_rate --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
 
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_cache_hit_rate --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_fetched_rows_rate --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_inserted_rows_rate --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_updated_rows_rate --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_returned_rows_rate --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_deleted_rows_rate --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	  
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_active_sessions --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  # instance metrics
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_shared_buffers --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_effective_cache --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_maintenance_work_mem --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_work_mem --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
 
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_active_sessions --labels=postgres --service-name=postgresql::postgres:5432 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected: expected/metrics-has-value-label.yml	
-     # slow sql
-    - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list --name=top_n_database_statement |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
-      expected:  expected/db-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_seq_page_cost --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_random_page_cost --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_max_wal_size --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_max_parallel_workers --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=meter_pg_instance_max_worker_processes --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries' -
+    expected:  expected/metrics-has-value.yml
+
+
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_cache_hit_rate --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_fetched_rows_rate --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_inserted_rows_rate --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_updated_rows_rate  --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_returned_rows_rate  --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_deleted_rows_rate --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics multiple-linear --name=meter_pg_instance_active_sessions --service-name=postgresql::postgres:5432 --instance-name=postgres-exporter:9187 |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected: expected/metrics-has-value-label.yml
+  # slow sql
+  - query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql records list --name=top_n_database_statement |yq e 'to_entries | with(.[] ; .value=(.value | to_entries))' -
+    expected:  expected/db-has-value.yml