github.com/Financial-Times/publish-availability-monitor@v1.12.0/README.md (about) 1 # publish-availability-monitor 2 [](https://circleci.com/gh/Financial-Times/publish-availability-monitor/tree/master) 3 [](https://goreportcard.com/report/github.com/Financial-Times/publish-availability-monitor) 4 [](https://coveralls.io/github/Financial-Times/publish-availability-monitor?branch=master) 5 [](https://codecov.io/gh/Financial-Times/publish-availability-monitor) 6 7 Monitors publish availability and collects related metrics. Collected metrics are sent to various systems (ex. Splunk, Graphite). 8 9 # Installation 10 11 1. Download the source code, dependencies, and build the binary: 12 13 ```shell 14 go get github.com/Financial-Times/publish-availability-monitor 15 go build 16 ``` 17 18 2. Set all environment variables listed in `startup.sh`. 19 20 3. Run 21 ````shell 22 startup.sh 23 ```` 24 25 With Docker: 26 27 ```shell 28 docker build -t coco/publish-availability-monitor . 29 ``` 30 31 ```shell 32 docker run -it \ 33 --env KAFKA_ADDR=<addr> \ 34 --env KAFKA_CLUSTER_ARN=<arn> \ 35 --env CONTENT_URL=<document store api article endpoint path> \ 36 --env LISTS_URL=<public lists api endpoint path> \ 37 --env PAGES_URL=<public pages api endpoint path> \ 38 --env NOTIFICATIONS_URL=<notifications read path> \ 39 --env NOTIFICATIONS_PUSH_URL=<notifications push path> coco/publish-availability-monitor 40 ``` 41 42 # Build and deploy 43 * Tagging a release in GitHub triggers a build in DockerHub. 44 45 # Endpoint Check Configuration 46 47 ``` 48 //this is the SLA for content publish, in seconds 49 //the app will check for content availability until this threshold is reached 50 //or the content was found 51 "threshold": 120, 52 ``` 53 54 ``` 55 //Configuration for the queue we will read from 56 "queueConfig": { 57 //URL(s) of the messaging system 58 "connectionString": "kafkaAddress", 59 //The group name by which this app will be knows to the messaging system 60 "consumerGroup": "YourGroupName", 61 //The topic we want to get messages from 62 "topic": "YourTopic", 63 //Threshold used to determine whether the consumer connection is lagging behind 64 "lagTolerance": 100 65 }, 66 ``` 67 68 ``` 69 //for each endpoint we want to check content against, we need a metricConfig entry 70 "metricConfig": [ 71 { 72 //the path (or absolute URL) of the endpoint. 73 //paths are resolved relative to the read_url setting (see below) on a per-environment basis 74 //to check content, the UUID is appended at the end of this URL 75 //should end with / 76 "endpoint": "endpointURL", 77 //used to associate endpoint-specific behavior with the endpoint 78 //each alias should have an entry in the endpointSpecificChecks map 79 "alias": "content", 80 //defines how often we check this endpoint 81 //the check interval is threshold / granularity 82 //in this case, 120 / 40 = 3 -> we check every 3 seconds 83 "granularity": 40 84 }, 85 { 86 "endpoint": "endpointURL", 87 "granularity": 40, 88 "alias": "pages", 89 "health": "/__public-pages-api/__health", 90 //optional field to indicate that this endpoint should only be checked 91 //for content of a certain type 92 //if not present, all content will be checked against this endpoint 93 "contentTypes": [""application/vnd.ft-upp-page""] 94 } 95 ], 96 ``` 97 98 ``` 99 //feeder-specific configuration 100 //for each feeder, we need a new struct, new field in AppConfig for it, and 101 //handling for the feeder in startAggregator() 102 "splunk-config": { 103 "logFilePath": "/var/log/apps/pam.log" 104 } 105 ``` 106 107 # Environment Configuration 108 The app checks environments configuration as well as validation credentials every minute (configurable) and it reloads them if changes are detected. 109 The monitor can check publication across several environments, provided each environment can be accessed by a single host URL. 110 111 ## File-based configuration 112 113 ### JSON example for environments configuration: 114 ```json 115 [ 116 { 117 "name":"staging-eu", 118 "read-url": "https://staging-eu.ft.com" 119 }, 120 { 121 "name":"staging-us", 122 "read-url": "https://staging-us.ft.com" 123 } 124 ] 125 ``` 126 127 ### JSON example for environments credentials configuration: 128 129 ```json 130 [ 131 { 132 "env-name": "staging-eu", 133 "username": "dummy-username", 134 "password": "dummy-pwd" 135 }, 136 { 137 "env-name": "staging-us", 138 "username": "dummy-username", 139 "password": "dummy-pwd" 140 } 141 ] 142 ``` 143 144 ### JSON example for validation credentials configuration: 145 ```json 146 { 147 "username": "dummy-username", 148 "password": "dummy-password" 149 } 150 ``` 151 152 Checks that have already been initiated are unaffected by changes to the values above. 153 154 ### Capability monitoring 155 The service performs monitoring of [business capabilities](https://tech.in.ft.com/guides/monitoring/how-to-capability-monitoring) by listening for specific e2e publishes on Kafka and reusing the existing endpoint configuration for scheduling the checks. 156 All capability monitoring metrics are sent to [Graphite](https://graphitev2-api.ft.com/) and are located under `Metrics/content-metadata/capability-monitoring` directory. 157 158 ### Kubernetes details 159 In K8s we're using the File-based configuration for environments, and the files are actually contents 160 from ConfigMaps as following: 161 162 - *environments configuration* is read from `global-config` ConfigMap, key `pam.read.environments` 163 - *credentials configuration* is read from secret `publish-availability-monitor-secrets`, key `read-credentials` 164 - *validation credentials* configuration is read from secret `publish-availability-monitor-secrets`, key `validator-credentials` 165 166 These keys can be modified on the fly and they will be picked up by the application without restart with a tiny delay. 167 More details on how this works [here](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#mounted-configmaps-are-updated-automatically)