@@ -946,4 +946,190 @@ Please refer the [page](./../registry/registry-permissions.md) for more details
946
946
947
947
## How to configure Authentication and Authorization ?
948
948
949
- Please refer the [ page] ( ./../../../docs/getting-started/concepts/permission.md ) for more details on how to configure authentication and authorization.
949
+ Please refer the [ page] ( ./../../../docs/getting-started/concepts/permission.md ) for more details on how to configure authentication and authorization.
950
+
951
+ ### Metrics
952
+
953
+ #### Get Resource Counts
954
+ - ** Endpoint** : ` GET /api/v1/metrics/resource_counts `
955
+ - ** Description** : Retrieve counts of registry objects (entities, data sources, feature views, etc.) for a project or across all projects.
956
+ - ** Parameters** :
957
+ - ` project ` (optional): Project name to filter resource counts (if not provided, returns counts for all projects)
958
+ - ** Examples** :
959
+ ``` bash
960
+ # Get counts for specific project
961
+ curl -H " Authorization: Bearer <token>" \
962
+ " http://localhost:6572/api/v1/metrics/resource_counts?project=my_project"
963
+
964
+ # Get counts for all projects
965
+ curl -H " Authorization: Bearer <token>" \
966
+ " http://localhost:6572/api/v1/metrics/resource_counts"
967
+ ```
968
+ - ** Response Example** (single project):
969
+ ``` json
970
+ {
971
+ "project" : " my_project" ,
972
+ "counts" : {
973
+ "entities" : 5 ,
974
+ "dataSources" : 3 ,
975
+ "savedDatasets" : 2 ,
976
+ "features" : 12 ,
977
+ "featureViews" : 4 ,
978
+ "featureServices" : 2
979
+ }
980
+ }
981
+ ```
982
+ - ** Response Example** (all projects):
983
+ ``` json
984
+ {
985
+ "total" : {
986
+ "entities" : 15 ,
987
+ "dataSources" : 8 ,
988
+ "savedDatasets" : 5 ,
989
+ "features" : 35 ,
990
+ "featureViews" : 12 ,
991
+ "featureServices" : 6
992
+ },
993
+ "perProject" : {
994
+ "project_a" : {
995
+ "entities" : 5 ,
996
+ "dataSources" : 3 ,
997
+ "savedDatasets" : 2 ,
998
+ "features" : 12 ,
999
+ "featureViews" : 4 ,
1000
+ "featureServices" : 2
1001
+ },
1002
+ "project_b" : {
1003
+ "entities" : 10 ,
1004
+ "dataSources" : 5 ,
1005
+ "savedDatasets" : 3 ,
1006
+ "features" : 23 ,
1007
+ "featureViews" : 8 ,
1008
+ "featureServices" : 4
1009
+ }
1010
+ }
1011
+ }
1012
+ ```
1013
+
1014
+ #### Get Recently Visited Objects
1015
+ - ** Endpoint** : ` GET /api/v1/metrics/recently_visited `
1016
+ - ** Description** : Retrieve the most recently visited registry objects for the authenticated user in a project.
1017
+ - ** Parameters** :
1018
+ - ` project ` (optional): Project name to filter recent visits (defaults to current project)
1019
+ - ` object ` (optional): Object type to filter recent visits (e.g., entities, features, feature_services)
1020
+ - ` page ` (optional): Page number for pagination (starts from 1)
1021
+ - ` limit ` (optional): Number of items per page (maximum 100)
1022
+ - ` sort_by ` (optional): Field to sort by (e.g., timestamp, path, object)
1023
+ - ` sort_order ` (optional): Sort order: "asc" or "desc" (default: "asc")
1024
+ - ** Examples** :
1025
+ ``` bash
1026
+ # Get all recent visits for a project
1027
+ curl -H " Authorization: Bearer <token>" \
1028
+ " http://localhost:6572/api/v1/metrics/recently_visited?project=my_project"
1029
+
1030
+ # Get recent visits with pagination
1031
+ curl -H " Authorization: Bearer <token>" \
1032
+ " http://localhost:6572/api/v1/metrics/recently_visited?project=my_project&page=1&limit=10"
1033
+
1034
+ # Get recent visits filtered by object type
1035
+ curl -H " Authorization: Bearer <token>" \
1036
+ " http://localhost:6572/api/v1/metrics/recently_visited?project=my_project&object=entities"
1037
+
1038
+ # Get recent visits sorted by timestamp descending
1039
+ curl -H " Authorization: Bearer <token>" \
1040
+ " http://localhost:6572/api/v1/metrics/recently_visited?project=my_project&sort_by=timestamp&sort_order=desc"
1041
+ ```
1042
+ - ** Response Example** (without pagination):
1043
+ ``` json
1044
+ {
1045
+ "visits" : [
1046
+ {
1047
+ "path" : " /api/v1/entities/driver" ,
1048
+ "timestamp" : " 2024-07-18T12:34:56.789Z" ,
1049
+ "project" : " my_project" ,
1050
+ "user" : " alice" ,
1051
+ "object" : " entities" ,
1052
+ "object_name" : " driver" ,
1053
+ "method" : " GET"
1054
+ },
1055
+ {
1056
+ "path" : " /api/v1/feature_services/user_service" ,
1057
+ "timestamp" : " 2024-07-18T12:30:45.123Z" ,
1058
+ "project" : " my_project" ,
1059
+ "user" : " alice" ,
1060
+ "object" : " feature_services" ,
1061
+ "object_name" : " user_service" ,
1062
+ "method" : " GET"
1063
+ }
1064
+ ],
1065
+ "pagination" : {
1066
+ "totalCount" : 2
1067
+ }
1068
+ }
1069
+ ```
1070
+ - ** Response Example** (with pagination):
1071
+ ``` json
1072
+ {
1073
+ "visits" : [
1074
+ {
1075
+ "path" : " /api/v1/entities/driver" ,
1076
+ "timestamp" : " 2024-07-18T12:34:56.789Z" ,
1077
+ "project" : " my_project" ,
1078
+ "user" : " alice" ,
1079
+ "object" : " entities" ,
1080
+ "object_name" : " driver" ,
1081
+ "method" : " GET"
1082
+ }
1083
+ ],
1084
+ "pagination" : {
1085
+ "page" : 1 ,
1086
+ "limit" : 10 ,
1087
+ "totalCount" : 25 ,
1088
+ "totalPages" : 3 ,
1089
+ "hasNext" : true ,
1090
+ "hasPrevious" : false
1091
+ }
1092
+ }
1093
+ ```
1094
+
1095
+ ** Note** : Recent visits are automatically logged when users access registry objects via the REST API. The logging behavior can be configured through the ` feature_server.recent_visit_logging ` section in ` feature_store.yaml ` (see configuration section below).
1096
+
1097
+ ---
1098
+
1099
+ ## Registry Server Configuration: Recent Visit Logging
1100
+
1101
+ The registry server supports configuration of recent visit logging via the ` feature_server ` section in ` feature_store.yaml ` .
1102
+
1103
+ ** Example:**
1104
+ ``` yaml
1105
+ feature_server :
1106
+ type : local
1107
+ recent_visit_logging :
1108
+ limit : 100 # Number of recent visits to store per user
1109
+ log_patterns :
1110
+ - " .*/entities/(?!all$)[^/]+$"
1111
+ - " .*/data_sources/(?!all$)[^/]+$"
1112
+ - " .*/feature_views/(?!all$)[^/]+$"
1113
+ - " .*/features/(?!all$)[^/]+$"
1114
+ - " .*/feature_services/(?!all$)[^/]+$"
1115
+ - " .*/saved_datasets/(?!all$)[^/]+$"
1116
+ - " .*/custom_api/.*"
1117
+ ` ` `
1118
+
1119
+ **Configuration Options:**
1120
+ - **recent_visit_logging.limit**: Maximum number of recent visits to store per user (default: 100).
1121
+ - **recent_visit_logging.log_patterns**: List of regex patterns for API paths to log as recent visits.
1122
+
1123
+ **Default Log Patterns:**
1124
+ - ` .*/entities/(?!all$)[^/]+$` - Individual entity endpoints
1125
+ - ` .*/data_sources/(?!all$)[^/]+$` - Individual data source endpoints
1126
+ - ` .*/feature_views/(?!all$)[^/]+$` - Individual feature view endpoints
1127
+ - ` .*/features/(?!all$)[^/]+$` - Individual feature endpoints
1128
+ - ` .*/feature_services/(?!all$)[^/]+$` - Individual feature service endpoints
1129
+ - ` .*/saved_datasets/(?!all$)[^/]+$` - Individual saved dataset endpoints
1130
+
1131
+ **Behavior:**
1132
+ - Only requests matching one of the `log_patterns` will be tracked
1133
+ - Only the most recent `limit` visits per user are stored
1134
+ - Metrics endpoints (`/metrics/*`) are automatically excluded from logging to prevent circular references
1135
+ - Visit data is stored per user and per project in the registry metadata
0 commit comments