brunoreboul / ram Goto Github PK
View Code? Open in Web Editor NEWReal-time Asset Monitor
License: Apache License 2.0
Real-time Asset Monitor
License: Apache License 2.0
Not blocking when using a service account to run ramcli that is hosted in a different project where Cloud Build API is activated
to keep it simple, two dashboards:
as sub queries per domain and prefix are launched in every dorectory
solution:
package dumpinventory
meth deployGRMMonitoringOrgBindings
the for loop exist with a return after dealing with the first org of the list, leading not to implrement the org run role in other monitored orgs
looking for potential similar for pattern in other services
Found other impacts:
Usually this corner case in not that visible as for many asset types the information is already provided by the RESOURCE feed
.
Nervertheless, this issue is visible when:
Fix: add the instance stream2bq_iam_assets
to the microservice stream2bq
configured to be triggered on the Pubsub topic cai-iam-policies
and writing to the BQ table assets
ram -config
configure stream2bq instances using method deployment.configureStream2bqAssetTypes()
in the package ramcli
AssetName pattern
//directories//groups//groupSettings
//directories//groups//members/
The number of groups
, groupsettings
and groupmembers
may be 10x the number of GCP assets.
There is not valuable ancestryPath for these assets.
In consequence these assets are not streamed into BQ asset
table. The cost/value ratio is too low.
In Last_compliancestatus
view, the assetType comes from the asset
table. Explaining while assetType
is empty for theses assets.
Workarround: update last_compliancestatus
view SQL code to deduct the assetType from the asset name for theses assets
www.googleapis.com/admin/directory/groups
www.googleapis.com/admin/directory/members
groupssettings.googleapis.com/groupSettings
Step #1 - "build a fresh ram cli": Already have image: golang
Step #1 - "build a fresh ram cli": go: github.com/BrunoReboul/[email protected]: missing go.sum entry; to add it:
Step #1 - "build a fresh ram cli": go mod download github.com/BrunoReboul/ram
Occurs on any build, including existing successful build when hitting RETRY
Cloud function GO runtime is bounded to GO v1.13
RAM developper’s GO version is aligned to the same version to avoid using new GO feature that won t be available on cloud functions.
go version go1.13.8 linux/amd64
Cloud Build environment uses the online GOLANG container that is continuously updated, currently using GO v1.16
Step #0 - "display go language version": Status: Downloaded newer image for golang:latest
Step #0 - "display go language version": docker.io/library/golang:latest
Step #0 - "display go language version": go version go1.16 linux/amd64
With GO 1.16 the -mod option for automatic updates default value changes
In Go 1.15 and lower, the -mod=mod flag was enabled by default, so updates were performed automatically. Since Go 1.16, the go command acts as if -mod=readonly were set instead: if any changes to go.mod are needed, the go command reports an error and suggests a fix.
Update the Cloud Build triggers build steps definition:
add go version to ease troubleshooting by always displaying which version of GO is used by the GOLANG Docker container
Add to the go build command the flag -mod=mod to allow automatic updates
steps:
- name: golang
args:
- go
- version
id: display go language version
- name: golang
args:
- go
- build
- '-mod=mod'
- ram.go
id: build a fresh ram cli
gfs.getDoc
when err text contains 'notfound' or 'not found' exit the retry loop
Running instances means:
The function gbq.getTable set a partition expiration to 24h, which is not requests ;-/
timePartitioning.Expiration, _ = time.ParseDuration("24h")
BQ doc: Updating the partition expiration
GO BQ module doc:
https://pkg.go.dev/cloud.google.com/go/bigquery#TimePartitioning
// The amount of time to keep the storage for a partition.
// If the duration is empty (0), the data in the partitions do not expire.
Expiration time.Duration
Set to 3600 sec instead of 600 sec
Always populated means:
Good practice, at least have owner and resolver described to each top level folders
To deal with emails in label value:
_dot_
by .
_at_
by @
marie-pierre_dot_dupondt_at_mycompany_dot_com
translates to [email protected]
Update the DataStudio report template accordingly to leverage owner and resolver
When searching about monitor service logs in Cloud Logging, I would like to filter log entries depending on the compliance result status. Then please add a field for that.
It could be one of:
In the current version I have to filter on the message field which starts with finish compliant|not_compliant
v0.3.2
specially when hitting CGI quotas
Context:
Proposed work arround:
New limit for could functions: 4GB
BigQuery streaming insertID field length max is 128
violation table insertID may be more than 1000 length
This issue did not popup before using cloud.google.com/go/bigquery 1.16.0
Proposed solution: hash the string the reduce its size
The underlying one way function preserving the BigQuery best effort to deduplicate
Example:
~/repos/ > ramcli -repo=./brunore-ram
2020/09/21 20:19:47 Path does not exist: ./go.mod
Multiple scenario means:
Example error when using ram -pipe
2020/10/22 18:35:33 grm projectsService.GetIamPolicy googleapi: Error 503: The service is currently unavailable., backendError
Where log.Fatal may be OK:
ramcli.Initialize
to avoid a breaking change on the RAM version upgrade mechanism, and there is not that much to test ramcli.Initialize
file name: constraints.xaml, constraints.csv
Example of yaml structure:
services:
- name: bq
rules:
- name: dataset_location
constraints:
- apiVersion: constraints.gatekeeper.sh/v1alpha1
kind: GCPBigQueryDatasetLocationConstraintV1
metadata:
name: myorg_sanboxes_europe_bq
File location: in monitor
folder
Add the file to .gitiignore
to avoid conflct
make it on anay ramcli execution
missing waitgroup.Wait()
For each core.go:
decommision initialRetryCheck
Menu means
servies/monitor/instances
the constraint name have a link to the constraint readme.md file
Log based metric
new set service similar to setdashboards
examples:
ram -pipe
without -service
nor -instance
means target all microservices all instances
weird means:
(^publish2fs_cloudresourcemanager_Folder-v\d*.\d*.\d*-prd)|(^publish2fs-v\d*.\d*.\d*-prd)|(^ram-v\d*.\d*.\d*-prd)|(^container_Cluster-v\d*.\d*.\d*-prd)
(^splitdump_single_instance-v\d*.\d*.\d*-prd)|(^splitdump-v\d*.\d*.\d*-prd)|(^ram-v\d*.\d*.\d*-prd)|(^bigquery_Dataset-v\d*.\d*.\d*-prd)
aka generalize what is already done in this test
As “RAM installer” I want “./ram -pipe” command implements automated retries to deal with cloud build create trigger transient backend errors so that time to (re)create all triggers is reduced avoiding manual retries
This issue does not only occur on a race.
It also occurs systematically in a multi org scenario, as multiple cloud functions (one per org) are deployed a different times on the sme service account (one per micro services). So the service account key used by the first deployed cloud function is killed by the second etc ..
Last update was on 2020-07-08
Update dependencies:
cloud.google.com/go v0.60.0 => v0.72.0
cloud.google.com/go/bigquery v1.9.0 => v0.13.0
cloud.google.com/go/firestore v1.2.0 => v1.3.0
cloud.google.com/go/logging v1.0.0 => v1.1.2
cloud.google.com/go/pubsub v1.4.0 => v1.8.3
cloud.google.com/go/storage v1.10.0 => v1.12.0
github.com/google/uuid v1.1.1 => v1.1.2
github.com/open-policy-agent/opa v0.21.0 => v0.24.0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d => v0.0.0-20201109201403-9fd604954f58
google.golang.org/api v0.28.0 => v0.35.0
google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5 => v0.0.0-20201119123407-9b1e624d6bc4
gopkg.in/yaml.v2 v2.3.0 => v2.4.0
Ideally, in a cell, the list of target(s) and in another cell the list of exclude(s) for each constraint.
Cloud function Instance dumpinventory_org_cloudresourcemanager_Organization deployment failed.
Cloud function names length is limited to 63
OrganizationIDs have variable lengh, the string length is 51 without the organizationID, leaving 12 for the organizationID while it can more more (seen 14)
Truncate cloud function mame to max 63
When errors occur during the initialize
function they are logged on purpose as basic log entry, so that the cloud function terminates without error to avoid retries.
As retry is avoided by design then the pubsub message is acknowledged, so that it is not persisted to bigquery leading to data losses.
This behavior addresses well non transient errors like 403 missing permission where 1) retry will not solve the 403 and 2) it avoids having to pay for compute time during 1 hours of retries.
On another hand, If the error is a transient that occurs for a proportion of execution, like 443: write: connection reset by peer
then it leads to data losses of the same proportion of pubsub message, while it would be worth retrying.
A group of instances means:
upload2gcs
have cloud build trigger assume an environment is provided to find the associated project hosting the triggers
In complement to succeed of failed (issue an error) the result should list what is found vs what is missing.
scope: convertfeed2logs, listgroups, listgroupmembers, getgroupsettings
impact: as new jey are create while not needed, and recorded to firestore, the running usefull key are no more protected (name overwritten in firestore), which will lead to deletion of running keys in a multi org scenarion at the next time the cloud function is instanciateed (exe initialize)
sfix: during deploy, only create a record keys when mode is not -check, to be implemented in the 4 impacted services
Step #2 - "deploy instance monitor_clouddns_rsasha1": 2020/10/21 07:33:48 dashboardService.List googleapi: Error 403: The caller does not have permission, forbidden
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.