Skip to content

Commit

Permalink
Merge pull request #15 from ImMin5/master
Browse files Browse the repository at this point in the history
Add metric data service
  • Loading branch information
ImMin5 authored Dec 10, 2024
2 parents d716ffe + d6d2044 commit 409d362
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 10 deletions.
16 changes: 10 additions & 6 deletions src/spaceone/inventory_v2/interface/grpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
from .job import Job
from .job_task import JobTask
from .metric import Metric
from .namespace_group import NamespaceGroup
from .namespace import Namespace
from .metric import Metric

# from .namespace_group import NamespaceGroup
# from .namespace import Namespace
from .metric_data import MetricData
from .metric_example import MetricExample

_all_ = ["app"]

Expand All @@ -15,6 +17,8 @@
app.add_service(Collector)
app.add_service(Job)
app.add_service(JobTask)
app.add_service(NamespaceGroup)
app.add_service(Namespace)
app.add_service(Metric)
# app.add_service(NamespaceGroup)
# app.add_service(Namespace)
app.add_service(Metric)
app.add_service(MetricData)
app.add_service(MetricExample)
2 changes: 1 addition & 1 deletion src/spaceone/inventory_v2/interface/grpc/metric_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from spaceone.core.pygrpc import BaseAPI
from spaceone.api.inventory_v2.v1 import metric_data_pb2, metric_data_pb2_grpc
from spaceone.inventory.service.metric_data_service import MetricDataService
from spaceone.inventory_v2.service.metric_data_service import MetricDataService


class MetricData(BaseAPI, metric_data_pb2_grpc.MetricDataServicer):
Expand Down
2 changes: 1 addition & 1 deletion src/spaceone/inventory_v2/interface/grpc/metric_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from spaceone.core.pygrpc import BaseAPI
from spaceone.api.inventory_v2.v1 import metric_example_pb2, metric_example_pb2_grpc
from spaceone.inventory.service.metric_example_service import MetricExampleService
from spaceone.inventory_v2.service.metric_example_service import MetricExampleService


class MetricExample(BaseAPI, metric_example_pb2_grpc.MetricExampleServicer):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
metric_id: metric-managed-created-count
name: Created Count
metric_type: COUNTER
resource_type: inventory.Asset
query_options:
group_by:
- key: provider
name: Provider
reference:
resource_type: identity.Provider
reference_key: provider
default: true
- key: asset_group_id
name: Asset Group
default: true
- key: asset_type_id
name: Asset Type
default: true
- key: region_code
name: Region
reference:
resource_type: inventory.Region
reference_key: region_code
- key: account
name: Cloud Account ID
- key: resource_id
name: Resource ID
- key: name
name: Resource Name
fields:
value:
operator: count
date_field: created_at
unit: Count
namespace_id: ns-managed-asset-change-history
version: '1.0'
29 changes: 29 additions & 0 deletions src/spaceone/inventory_v2/managed_resource/metric/total_count.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
metric_id: metric-managed-total-count
name: Total Count
metric_type: GAUGE
resource_type: inventory.Asset
query_options:
group_by:
- key: provider
name: Provider
reference:
resource_type: identity.Provider
reference_key: provider
default: true
- key: asset_type_id
name: Asset Type
default: true
- key: region_id
name: Region
reference:
resource_type: inventory.Region
reference_key: region_code
- key: account
name: Cloud Account ID
fields:
value:
operator: count
unit: Count
namespace_id: ns-managed-asset-summary
version: '1.0'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from spaceone.core.model.mongo_model import QuerySet
from spaceone.core.manager import BaseManager
from spaceone.inventory.model.metric_example.database import MetricExample
from spaceone.inventory_v2.model.metric_example.database import MetricExample

_LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/spaceone/inventory_v2/model/metric/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MetricSearchQueryRequest(BaseModel):
is_managed: Union[bool, None] = None
exists_only: Union[bool, None] = None
namespace_id: Union[str, None] = None
workspace_id: Union[str, list, None] = None
workspace_id: Union[list, str, None] = None
domain_id: str


Expand Down

0 comments on commit 409d362

Please sign in to comment.