{"id":28003157,"url":"https://github.com/fnproject/ext-statsapi","last_synced_at":"2025-05-09T01:59:14.466Z","repository":{"id":57605001,"uuid":"111400439","full_name":"fnproject/ext-statsapi","owner":"fnproject","description":"Fn extension to extend the Fn API to provide statistical metrics","archived":false,"fork":false,"pushed_at":"2018-02-01T10:18:57.000Z","size":91,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-09T01:59:10.779Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-20T11:15:30.000Z","updated_at":"2018-01-31T13:30:31.000Z","dependencies_parsed_at":"2022-09-26T20:01:17.817Z","dependency_job_id":null,"html_url":"https://github.com/fnproject/ext-statsapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fext-statsapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fext-statsapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fext-statsapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Fext-statsapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnproject","download_url":"https://codeload.github.com/fnproject/ext-statsapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176436,"owners_count":21866142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-09T01:59:13.824Z","updated_at":"2025-05-09T01:59:14.444Z","avatar_url":"https://github.com/fnproject.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fn server extension to provide a statistics API \n\nThis is a Fn extension that extends the Fn API to provide some basic statistics about the operation of the Fn server. \n\nThe API uses Prometheus internally which allows statistics to be combined from multiple Fn servers,\nnot just the one which is handling the request.\n\nSince this is an extension it is not included in the core Fn server: \nto use it you need to build a custom Fn server, configured to include this extension.\nThis API also requires a Prometheus server to be running.\n\nThere are two examples which describe how to build a custom version of the Fn server.\nThey also describe how to start Prometheus \nand how to configure the custom Fn server and Prometheus to connect to one another.\n\n* [How to build a custom Fn server docker image](./examples/operators/README.md) (mainly of interest to end users and operators)\n* [How to build a custom Fn server executable](./examples/developers/README.md) (mainly of interest to developers working on the statistics API extension itself)\n\nThe following example describes how to use the statistics API to obtain aggregated statistics from a cluster of Fn servers:\n* [How to use the statistics API extension with a cluster of custom Fn servers](./examples/operators-clustered/README.md)\n\n## Try some API calls\n\nIf you have Prometheus and a custom Fn server running as described in these examples, \nyou can then deploy and run some functions and obtain information about them using the statistics API extension.\n\n### Statistics for all applications\n\nThe following API call requests metric values for the past five minutes, with an interval of 30s between values.\n\n```sh\ncurl 'http://localhost:8080/v1/stats'\n```\n\nTo specify a different time range and interval see [Time and step parameters](#time-and-step-parameters) below \n\n### Statistics for a single application\n\nTo obtain statistics for a single application `hello-async-a`:\n```sh\ncurl 'http://localhost:8080/v1/apps/hello-async-a/stats'\n```\n### Statistics for a single route\n\nTo obtain statistics for a single route `hello-async-a1` in application `hello-async-a`:\n```sh\ncurl 'http://localhost:8080/v1/apps/hello-async-a/routes/hello-async-a1/stats'\n```\n\n### Time and step parameters\n\nThe following API call requests metric values for the time period from `starttime` to `endtime`, with an interval of `step` between values. (You will need to replace the example values of `starttime` to `endtime` shown below with more recent times or you won't get any statistics.)\n\n```sh\ncurl 'http://localhost:8080/v1/stats?starttime=2017-11-24T18:01:30.851Z\u0026endtime=2017-11-24T18:11:30.849Z\u0026step=30s'\n```\n\n`starttime` and `endtime` should be of the form `2017-11-24T18:01:30.851Z`\n\n`step` should be a number followed by a time unit, such as `30s` or `5m`.\n\n## Response format\n\nHere is a sample response:\n\n```json\n{\n  \"status\":\"success\",\n  \"data\":{\n    \"calls\":[\n      {\n        \"time\":1512416119,\n        \"value\":12\n      },\n      {\n        \"time\":1512416149,\n        \"value\":20\n      },\n      {\n        \"time\":1512416179,\n        \"value\":34\n      },\n      {\n        \"time\":1512416209,\n        \"value\":41\n      }\n    ],\n    \"completed\":[\n      {\n        \"time\":1512416119,\n        \"value\":10\n      },\n      {\n        \"time\":1512416149,\n        \"value\":15\n      },\n      {\n        \"time\":1512416179,\n        \"value\":28\n      },\n      {\n        \"time\":1512416209,\n        \"value\":35\n      }\n    ],\n    \"errors\":[\n      {\n        \"time\":1512416119,\n        \"value\":1\n      },\n      {\n        \"time\":1512416149,\n        \"value\":3\n      },\n      {\n        \"time\":1512416179,\n        \"value\":3\n      },\n      {\n        \"time\":1512416209,\n        \"value\":3\n      }\n    ],   \n    \"timeouts\":[\n      {\n        \"time\":1512416119,\n        \"value\":1\n      },\n      {\n        \"time\":1512416149,\n        \"value\":2\n      },\n      {\n        \"time\":1512416179,\n        \"value\":3\n      },\n      {\n        \"time\":1512416209,\n        \"value\":3\n      }\n    ],           \n    \"durations\":[\n       {\n         \"time\":1512416119,\n         \"value\":13.310655658088855\n       },\n       {\n         \"time\":1512416149,\n         \"value\":14.841753632280154\n       },\n       {\n         \"time\":1512416179,\n         \"value\":34.04480194936709\n       },\n       {\n         \"time\":1512416209,\n         \"value\":45.51680103676471\n       }\n     ],\n    \"failed\":[]\n  }\n}\n```\n\nThe `success` element will be set to `success` if the API call is successful. \nIf the API call is unsuccessful then the `success` element will be set to `error` and an additional element `error` will contains a description of the failure.\n\nThe `data` element contains elements `calls`, `completed`, `errors`, `timeouts` and `durations`. \n\n* The `calls` element is an array of objects. Each object contains a single observation of the `fn_calls` counter metric at a specific time. This is a count of the number of function calls made since the server was started.\n\n* The `completed` element is an array of objects. Each object contains a single observation of the `fn_completed` counter metric at a specific time. This is a count of the number of successful function calls since the server was started.\n\n* The `errors` element is an array of objects. Each object contains a single observation of the `fn_errors` counter metric at a specific time.\nThis is a count of failed (but not timed out) function calls since the server was started.\nIf there were no errors the array may be empty.  \n\n* The `timeouts` element is an array of objects. Each object contains a single observation of the `fn_timeouts` counter metric at a specific time.\nThis is a count of timed out function calls since the server was started.\nIf no function calls timed out function the array may be empty.  \n\n* The `durations` element is an array of objects. Each object contains a single calculated value of the rolling mean `fn_span_agent_submit_duration_seconds` histogram metric, where the rolling mean is calculated over a period of one minute. \n\nIn addition the `data` element contains the element `failed`. This is included for backward compatibility. It is deprecated and will be removed in the future.\n\n* The `failed` element is an array of objects. Each object contains a single observation of the `fn_failed` counter metric at a specific time.\nThis is a count of failed or timed out function calls since the server was started.\nIf there were no failures the array may be empty.  \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Fext-statsapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnproject%2Fext-statsapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Fext-statsapi/lists"}