mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
4afa7d8e9f5c716c4bf16af2eb0291f495ebc708
17
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b2e3870c06 | feat(logs): deliver log events through subscription filters (#5021) | ||
|
|
94ea065cc3 |
docs(cloudwatch): describe how Logs Insights fails unsupported syntax (#4717)
Since #3139 an unsupported command or filter operator fails the query (GetQueryResults reports status Failed) instead of being dropped with a warning. The Logs Insights section still described the old behaviour, where the stage was skipped and every row came back. Update the table to the current behaviour, note that the reason is only in the server log, and keep the compound-filter case, which still returns no rows with status Complete and no log line. |
||
|
|
1d646c6fea |
fix(cloudwatch): retain metric-math alarm query definitions (#4594)
* fix(cloudwatch): retain metric-math alarm query definitions * test(cloudwatch): use shared XML parser for alarm assertions |
||
|
|
a0cb86cc13 |
fix(cloudwatchlogs): journal log events instead of rewriting the store under persistent mode (#4187)
* perf(storage): append WAL batches once and skip compaction of an unchanged store A putAll batch was N locked appends and N flushes; it is now one contiguous run of records and one flush. Compaction rewrote the snapshot on every tick even when nothing had changed since the last one, so an idle store kept rewriting its file; the store now tracks whether it changed and compaction returns early otherwise. Entries replayed from the log at load mark the store changed so the next compaction folds them in. * fix(storage): recover from a corrupt WAL tail instead of failing boot The replay reader trusted the signed length headers it read: a negative length threw IllegalArgumentException out of load() and failed the owning service at boot, and a length past the end of the file read to EOF. After any stop, the writer reopened behind the unreadable bytes, so every entry appended after a torn tail was lost on the next load until a compaction happened. Lengths are now bounded by the bytes left in the file, every framing or decode failure stops replay with a warning, and the unreadable tail is cut off before the writer reopens. An unreadable snapshot is quarantined to a .corrupt sibling like the other file-backed stores do, instead of being overwritten by the next compaction. * fix(storage): journal append-heavy stores under persistent mode PersistentStorage rewrites the whole store file on every mutation, so the cost of a write grows with the store. A store can now declare an APPEND_HEAVY write profile on StorageFactory.create; under persistent mode such a store is backed by WalStorage with the store's own JSON file as the snapshot and a .wal file next to it. The snapshot layout means an existing store file is picked up as the first snapshot and the file is current again after a clean shutdown, so no migration is needed in either direction. The other modes ignore the profile. * fix(cloudwatchlogs): journal log events under persistent storage Every PutLogEvents batch rewrote the whole cwlogs-events.json file under persistent mode, so the cost of one batch grew with the number of stored events. The events store now declares the APPEND_HEAVY write profile: a batch is appended to cwlogs-events.wal and the JSON file is rewritten on the WAL compaction interval and at shutdown. Groups, streams, filters and policies keep the file that is rewritten on every call. Closes #2500 * docs(storage): describe journaled stores under persistent mode Explain that CloudWatch Logs events are journaled to cwlogs-events.wal under persistent mode, that the compaction interval now governs that store too, and that the JSON file is current after a clean shutdown and up to one interval behind while running. Also corrects the documented CloudWatch Logs flush interval default from 5000 to 15000, which is what EmulatorConfig ships. * docs(storage): describe journaled stores as append-heavy The pages said the CloudWatch Logs event store only ever grows, but the 20,000-event cap, retention pruning and DeleteLogStream all remove events. What qualifies a store for journaling is its write pattern, which is what WriteProfile.APPEND_HEAVY says, so the pages now say that. |
||
|
|
22b0627245 |
test(compat): assert recorded metric filter publishing through the SDK modules (#3809)
* feat(logs): add metric filters with per-event metric publication Implements PutMetricFilter, DescribeMetricFilters, DeleteMetricFilter and TestMetricFilter on the CloudWatch Logs JSON 1.1 handler, backed by a filter pattern engine for term, space-delimited and JSON patterns. The grammar is checked against 148 TestMetricFilter cases recorded from AWS, kept as fixtures under src/test/resources/cloudwatchlogs and recaptured with the opt-in script under tools/aws-capture/cloudwatchlogs. Validation follows the observed AWS wire behavior: the five regex-bearing filters per log group quota is shared with subscription filters through one canonical backend monitor, a filter pattern may hold at most two regular expressions, defaultValue must be a JSON number, DescribeMetricFilters requires metricName and metricNamespace together in both directions, and TestMetricFilter reports one-based event numbers with an empty public extractedValues map for JSON patterns. Ingested events publish samples into CloudWatch Metrics per event at the event timestamp: matching events contribute the extracted or literal value, non-matching events contribute defaultValue, dimensions are all-or-none, and system dimensions only attach to matching events. Failed publications are retried from a bounded queue of 10,000 samples with stable publication ids. Resettable gains beforeReset and afterReset default hooks so the metric filter publisher can pause and drain before a state reset wipes storage and resume afterwards. EmulatorInfoController.performReset is serialized and calls the hooks around the existing container teardown and storage wipe, running afterReset in a finally block so a failed wipe cannot leave a publisher paused. The GetMetricStatistics and GetMetricData Query responses now carry the CloudWatch namespace so both read paths return the same samples. * feat(cloudformation): provision AWS::Logs::MetricFilter Adds LogsMetricFilterCfnProvisioner for creates, in-place updates, name changes and deletes. Ref and PhysicalResourceId are the filter name alone, as observed on AWS; the log group is kept as private resource metadata. A replacement deletes the old filter before creating the new one, matching the DELETE then CREATE event order AWS emits, and a failed replacement recreates the previous definition on rollback. Every mutation records an APPLIED, NOT_APPLIED or UNKNOWN outcome under the service lock so a failed or ambiguous call can never authorize deleting or overwriting a filter the stack does not own. Ownership that cannot be proven is resolved conservatively before the next mutation. The engine gains three small provisioner hooks that this type needs and others may reuse: - ProvisionContext carries a progress consumer so a provisioner can emit the intermediate DELETE_IN_PROGRESS and DELETE_COMPLETE events of a delete-first replacement while provision is still running. - rollbackUpdate(resource, progress) lets a provisioner restore its own previous state during UPDATE_ROLLBACK and report the steps as events. - hasPendingRollbackCleanup and retainsFailedUpdateState let a provisioner tell the engine that an UPDATE_FAILED resource still holds its own rollback snapshot, so the engine neither restores the previous resource over it nor refuses a later DeleteStack. Both default to false; only this provisioner overrides them. The type is listed in supported-resource-types.tsv, the generated resource table and CfnProvisionerFixture, with unit, integration, storage reload and SDK coverage. * docs(logs): document metric filters and the AWS verification record Describes the metric filter operations, publication semantics and CloudFormation support in docs/services/cloudwatch.md and adds cloudwatch-metric-filters-verification.md, the record of what was observed on AWS in eu-west-1, with which tools, and where each recorded fixture came from. Registers the handler and the verification page with the docs tooling and teaches the service inventory test to count facet pages. * feat(logs): publish metric filter samples off the PutLogEvents thread PutLogEvents evaluated each filter and wrote one CloudWatch Metrics sample per filter and event on the request thread while holding the filter-store monitor, up to a million writes for a maximal request, so ingestion latency depended on the Metrics sink and every PutMetricFilter waited behind the whole batch. The request thread now only evaluates the group's filters as they are at ingestion and hands the resulting immutable samples, with their stable publication ids, to a bounded queue of 100,000 samples. The existing single worker drains it and writes one sample per monitor acquisition, so a PutMetricFilter or a reset waits for at most one write. A batch that does not fit the queue is written inline on the request thread rather than dropped. Failed writes still land in the 10,000 sample retry map with the same ids and cadence as before. Reset pauses the worker, discards queued and failed samples and bumps a generation counter so a batch taken before the reset is never written into the wiped store. Shutdown drains the queue before storage shuts down and clears the retry map only after the worker has terminated. Samples ingested while Metrics is disabled are discarded at startup. Integration and SDK tests poll for the sample, as they would against AWS. * test(compat): assert recorded metric filter publishing through the SDK modules Extends the Java compatibility module with the publishing scenarios recorded from AWS: mixed defaults and quiet traffic, extraction and ordinary dimension series, system dimensions on matches only, and a Sum alarm driven by quiet defaults. Each series is read through the SDK's CloudWatch JSON protocol and again as a signed legacy Query request, so GetMetricStatistics and GetMetricData agree on every sample, timestamp, unit and dimension set. Expected values come from module-local copies of the root fixture metric-filter-publishing-aws.json. MetricFilterFixturePackagingTest checks the Java copy loads from the classpath and the root CloudWatchLogsMetricFilterFixturePackagingTest fails when either SDK module copy drifts from the root file. The Python module gains tests/metric_filter_replay.py, an opt-in replay of the same scenarios against a Floci endpoint or, with explicit profile, region and write acknowledgement, against AWS. Its logic is covered offline by tests/test_metric_filter_replay.py with the network blocked. Both module Dockerfiles are unchanged: the Java image already runs the whole suite and the Python image already copies tests/. * test(compat): assert every recorded statistic and poll for published samples The SDK publishing assertions compared only Sum and SampleCount although the AWS fixture also records Minimum and Maximum for the default-value scenarios. Both the SDK JSON reads and the signed legacy Query reads now assert every statistic the fixture carries, on GetMetricStatistics and GetMetricData. Publication now happens shortly after PutLogEvents returns, so present series are polled and absent series are asserted only after a later positive control of the same filter is visible, which the publisher's ordering guarantees. The read window ends at second 59 so a sample stamped on the following minute is never in scope. The live replay's Region check names the commercial partition explicitly. botocore already defaults get_available_regions to partition_name="aws", so GovCloud and China Regions were rejected before; the offline test now pins it. * test(compat): keep the metric filter SDK test on the Java 17 API of the compat image List.getLast() is Java 21; the sdk-test-java image compiles with Temurin 17. |
||
|
|
460aa0718e |
feat(cloudwatch): provision AWS::CloudWatch::Dashboard (#3231)
* feat(cloudwatch): provision AWS::CloudWatch::Dashboard The dashboard name is the physical id, generated when the template gives none and kept across updates. An update with the same name puts the body again and drives the tags to the template's set, since PutDashboard leaves an existing dashboard's tags alone. A changed name creates the new dashboard and leaves the displaced one to the ReplacementCleanup record, which deletes it once the update commits or restores it on rollback. The body may be written as a JSON object in the template and is stored as the string the API takes. The CloudWatch docs now list the dashboard and tag actions the handlers already serve. * fix(cloudwatch): roll back in-place dashboard updates and replace a dashboard whose explicit name is dropped An in-place update keeps the body and tags it replaces on the resource, or the fact that the dashboard did not exist, and a failed stack update puts them back in full. The name mode is recorded as the Logs provisioner does, so a template that drops an explicit DashboardName gets a generated name and a replacement, as on AWS, while an unnamed dashboard keeps its generated name. The Tags list is checked against the schema's cap of 50 on every provision, since the tag operations an update reconciles through do not enforce it. The integration test reads stack events with XmlParser. * fix(cloudwatch): keep the dashboard rollback snapshot until the restore succeeds A restore that throws left no snapshot behind, so the next rollback attempt reported success without restoring anything. The snapshot is now spent only after the body and tags are back. * fix(cloudwatch): unwind a dashboard update that failed after it changed the body An in-place update puts the body and then reconciles the tags. When the tag calls failed, the exception left the dashboard carrying the new body while CloudFormationService put the resource the stack held before the attempt back in its place. That object never carried the snapshot taken by the attempt, so the walker marked it restored and skipped rollbackUpdate: the stack reported a completed rollback over a dashboard that still had the update's body, or a half reconciled set of tags. The mutating calls now unwind themselves through rollbackUpdate, the way IotDomainConfigurationCfnProvisioner unwinds a replacement, and report the resource restored. An unwind that cannot put the body back keeps the snapshot and records the failure on the resource, so the stack ends in UPDATE_ROLLBACK_FAILED rather than claiming the prior dashboard is intact, and the original failure is still what the stack reports. Tests: anInPlaceUpdateThatFailedOnItsTagsPutsTheBodyBack, anUnwoundInPlaceUpdateIsMarkedRestored, anUnwindThatCannotRestoreIsReportedAsARollbackFailure. * fix(cloudwatch): record a dashboard unwind failure before joining it to the update failure The unwind repeats the tag call the update just made, so a service that keeps failing hands the unwind the very exception that interrupted the update. Throwable.addSuppressed rejects a throwable suppressed under itself, and that IllegalArgumentException escaped the unwind before the rollback failure was recorded: the dispatcher reported "Self-suppression not permitted" as the resource failure, no failure attribute reached the stored resource, and the stack ended UPDATE_ROLLBACK_COMPLETE over a dashboard whose tags were never put back. The failure attribute is now written first and the two exceptions are joined only when they differ, as PipesCfnProvisioner does. Two stack-level tests drive the whole path through CloudFormationService with a spied CloudWatchDashboardsService, the way CloudFormationPipesCleanupIntegrationTest does: a one-off tag failure ends in UPDATE_ROLLBACK_COMPLETE with the prior body and tags live, a persistent one in UPDATE_ROLLBACK_FAILED naming the dashboard and carrying the unwind's reason. Tests: anUnwindThatFailsWithTheUpdatesOwnExceptionIsStillRecorded, anUpdateThatFailedOnItsTagsPutsTheDashboardBackAndTheStackRollsBackCleanly, aFailedRestoreLeavesTheStackInUpdateRollbackFailedNamingTheDashboard. |
||
|
|
5b7c2c4a62 |
feat(cloudwatch): store and serve metric stream definitions (#3214)
* feat(cloudwatch): store and serve metric stream definitions PutMetricStream, GetMetricStream, ListMetricStreams, DeleteMetricStream, StartMetricStreams and StopMetricStreams work over Query and JSON. A stream is a definition with a running or stopped state, and nothing is delivered to the Firehose delivery stream it names. The service lives in its own metricstreams package next to dashboards and is injected into both handlers, and the tag operations route a metric-stream ARN to it. Ported from lex00/floci#42. * fix(cloudwatch): validate nested metric stream members, page ListMetricStreams, keep batches atomic StartMetricStreams and StopMetricStreams resolve every requested name before changing any, so a batch naming a missing stream fails as a whole. PutMetricStream now checks the nested members: a filter needs a Namespace, an IncludeMetrics entry needs a Namespace and a MetricName, and a statistics configuration needs non-empty IncludeMetrics and AdditionalStatistics. ListMetricStreams pages through the shared Pagination helper with MaxResults and NextToken over both protocols. * fix(cloudwatch): answer an unknown name on StartMetricStreams and StopMetricStreams with InvalidParameterValue The model declares ResourceNotFoundException on GetMetricStream alone. Start and Stop declare InvalidParameterValue, so an unknown name in the batch answers that, still after resolving every name before any change. |
||
|
|
6a728f1b9f |
feat(cloudwatchlogs): add cross-account policy operations (#3089)
* feat(cloudwatchlogs): add cross-account policy operations * fix(cloudwatchlogs): align cross-account policy contracts * fix(cloudwatchlogs): enforce account policy quotas * fix(cloudwatchlogs): validate field index policy scopes * fix(cloudwatchlogs): parse field index criteria safely * fix(cloudwatchlogs): align field index quota parsing |
||
|
|
4435c62848 |
feat(logs): add AssociateKmsKey and DisassociateKmsKey for log groups (#2584)
* feat(logs): AssociateKmsKey / DisassociateKmsKey for log groups
floci had no CloudWatch Logs KMS association at all, so LZA's
Custom::UpdateSubscriptionFilter Lambda got UnsupportedOperation, the
resource reported FAILED, AWSAccelerator-LoggingStack rolled back, and
CDK's readback surfaced the misleading "NoStack: CloudFormationStack
object does not hold a stack".
The Lambda reads logGroup.kmsKeyId from DescribeLogGroups and only calls
AssociateKmsKey when it differs from the target key ARN, so storing the
association is not enough -- DescribeLogGroups has to echo kmsKeyId back
or the association never converges and it re-associates every deploy.
- LogGroup: kmsKeyId field
- CloudWatchLogsService: associateKmsKey / disassociateKmsKey, both
ResourceNotFoundException on an unknown group; associate rejects a
blank kmsKeyId with InvalidParameterException
- CloudWatchLogsHandler: AssociateKmsKey / DisassociateKmsKey actions
(name or ARN identifier), and kmsKeyId emitted by DescribeLogGroups
only when a key is associated
(cherry picked from commit d548de18dc5c5dc8de96cb3b37a3935915be9da2)
* fix(logs): accept resourceIdentifier on Associate/DisassociateKmsKey and require an identifier
The ARN alternative for these two operations is resourceIdentifier on the
wire (unlike the query operations' logGroupIdentifier), so SDK requests
identifying the group by ARN previously failed with ResourceNotFoundException.
A request with neither identifier now returns InvalidParameterException
instead of resolving a null group name. Both actions documented in the
cloudwatch supported-actions table.
* fix(logs): reject KMS requests naming both logGroupName and resourceIdentifier
AWS models the two identifiers as mutually exclusive — exactly one is
required. Supplying both previously succeeded against the named group
while silently ignoring the ARN target.
* fix(logs): enforce the modeled input constraints on the pre-existing operations
logEvents (1-10000 on PutLogEvents), logStreamNames (1-100 on
FilterLogEvents) and the Random/ByLogStream distribution enum on
PutSubscriptionFilter now answer the modeled InvalidParameterException
instead of being accepted verbatim. Included here because this PR
already hardens the same handler; found by a model-grounded constraint
sweep.
* fix(logs): treat a present-but-blank KMS target identifier as present
A blank logGroupName beside a valid resourceIdentifier slipped past the
exclusivity check as "absent" and the mutation proceeded on the valid
field. Presence is now membership (non-null), and a blank chosen
identifier is rejected outright — the model pins both to min length 1.
* fix(logs): store kmsKeyId on CreateLogGroup, reject query-result identifiers, and treat null lists as absent
CreateLogGroup modeled kmsKeyId but the handler never read it, so an
encrypted-at-creation request was accepted, stored nowhere, and absent
from DescribeLogGroups. Both AssociateKmsKey and DisassociateKmsKey
resolve resourceIdentifier through extractLogGroupNameFromArn, which
only recognizes the :log-group: form; the modeled :query-result: form
(account-wide GetQueryResults encryption, a separate feature) fell
through unchanged and became a misleading ResourceNotFoundException
naming a log group the caller never specified. FilterLogEvents also
used request.has("logStreamNames"), which is true for an explicit
JSON null, tripping the min-1 bound the same way an empty array does;
AWS treats an explicit null on an optional member as absent.
Fixes all three: plumb kmsKeyId through a new createLogGroup overload
and store it when non-blank; recognize and reject the query-result
resourceIdentifier form as unsupported instead of mangling it; switch
to hasNonNull for logStreamNames, matching the idiom already used in
resolveKmsTargetLogGroupName. Also fixes requireListSize's
fully-qualified JsonNode parameter and a stray blank line.
|
||
|
|
859db2f352 | feat(cloudwatch-logs): add resource policy actions (#2574) | ||
|
|
112602fc6e |
fix(cloudwatch): page FilterLogEvents forward with a usable nextToken (#2354)
FilterLogEvents returned UUID.randomUUID() as its nextToken and had no nextToken parameter to accept one back, so a response could advertise more results while giving a client no way to reach them. Truncation compounded it: the time and pattern filters ran before .limit(maxEvents) over an ascending-sorted list, so an over-cap query kept the oldest matches and the newest were unreachable. The canonical use of this action is finding the error that just happened across a group, which is exactly the event most likely to be dropped. Accept a nextToken and make it an f/<index> offset into the matched set, reusing the parser GetLogEvents already validates its tokens with so a malformed, negative or overflowing token raises InvalidParameterException here too. The offset indexes matches rather than stored events, so a request narrowed by pattern, time range or stream names pages through only what it matched. Emit the token only when a further page exists, unlike GetLogEvents which echoes its forward token back. The two AWS actions signal exhaustion differently: FilterLogEvents documents an absent nextToken as "pagination is finished", and its SDK paginators keep requesting while the token is present with no same-token guard, so echoing a final token would never terminate. Also refuse to emit a cursor that cannot advance, which a max-events cap configured to zero would otherwise produce, and compute the page end by subtracting from the total so a cap near Integer.MAX_VALUE cannot overflow the index negative. startFromHead is still unsupported, so results run oldest first. |
||
|
|
4215006fe2 |
feat(logs): support log group deletion protection (#2256)
* fix(logs): accept log group deletion protection lifecycle * feat(logs): support log group deletion protection |
||
|
|
f1c81977ec |
fix(cloudwatch): warn on unsupported Logs Insights filter operators (#2170)
parseFilter scans for the leftmost '!=', '==' or '=' outside a quoted
value, so the '=' inside '>=', '<=' and '=~' won. For '>=' and '<=' the
comparison character was absorbed into the field name ("@message >"),
which resolves to null for every row, and passesFilters treats null as
non-matching; for '=~' the value became the literal "~ /ERROR/". Either
way the query came back with no rows and no warning, because as far as
parseFilter was concerned it had found a valid operator.
Stop the scan when a position starts one of those three operators, so
control reaches the "Ignoring unsupported Logs Insights filter" warning
that '<', '>', 'like', 'not like' and 'in' already hit, and the stage is
dropped instead. Quote tracking is untouched, so a '>=' inside a quoted
value is still just part of the value.
The docs table describing how unsupported syntax degrades had the same
two cases inverted: '=~' listed as warn-and-drop when it mis-parsed, and
bare '<' / '>' as silent-zero-rows when they already warned. Folded into
the one row that now matches the code, and the compound and/or mis-parse
this change does not fix got its own row instead of staying implied.
Refs #2042
|
||
|
|
86134e8c7f |
docs(cloudwatch): document Logs Insights subset and missing Logs actions (#2044)
docs/services/cloudwatch.md listed 14 of the 24 actions that CloudWatchLogsHandler dispatches. The handler is on the deferred_handlers allowlist in tools/docs/services.yaml, so the table is maintained by hand and had drifted as actions were added. Most notably Logs Insights (StartQuery / GetQueryResults / StopQuery, added in 1.5.31) was undocumented, leaving no way to discover which parts of the query language are implemented. Add the 10 missing actions and a Logs Insights section covering the supported commands, the field syntax, and how each kind of unsupported input degrades: a dropped filter stage returns every row, a >= or <= comparison is mis-parsed into a field name and returns none, a missing projected field becomes an empty string, and an unrecognised sort direction falls back to ascending. Also note the PutSubscriptionFilter and GetDataProtectionPolicy simplifications, document FLOCI_SERVICES_CLOUDWATCHLOGS_QUERY_COMPLETION_DELAY_MS in both the service page and the central environment-variable list, correct the MAX_EVENTS_PER_QUERY description, and add a start-query example. |
||
|
|
9e35046647 |
Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml * docs: sync with main and new features * docs: reverting docker-compose.yml |
||
|
|
a32b7f1f3b |
docs: comprehensive audit sweep + CHANGELOG backfill (1.1.0-1.5.2) (#326)
CHANGELOG.md was empty for the 1.1.0-1.5.2 release cycle and service docs had drifted from code behaviour. This sweep reconciles docs against the current codebase on upstream/main. - Backfill CHANGELOG.md for 1.1.0 through 1.5.2 from git history - Correct exact operation counts in docs/services/index.md: S3 (~30 -> 58), Lambda (~25 -> 30), API Gateway v1 (~24 -> 62). Counts now come from the actual dispatch handlers rather than @Path annotation counts. - Rewrite README "Supported Services" table to drop per-service op counts (they drift too fast); point readers at docs/services/index.md - Update 24 service docs for accuracy, add "Not Implemented" sections where relevant (s3.md, lambda.md, api-gateway.md) - Refresh configuration and getting-started docs - Add EventBridge Scheduler and AppConfig to mkdocs nav - Add AppConfig / AppConfigData rows to README and services index following the 1.5.2 upstream release |
||
|
|
61433f59ab | firt commit |