The Specified Time Range Was Too Small. Please Try Again With A Time Range Longer Than 20 Minutes

1 view
Skip to first unread message

Courtland Boland

unread,
Aug 4, 2024, 9:41:05 PM8/4/24
to cornsellcluschar
Everyday many thousands of developers make requests to the X API. To help manage the sheer volume of these requests, limits are placed on the number of requests that can be made. These limits help us provide the reliable and scalable API that our developer community relies on.

The maximum number of requests that are allowed is based on a time interval, some specified period or window of time. The most common request limit interval is fifteen minutes. If an endpoint has a rate limit of 900 requests/15-minutes, then up to 900 requests over any 15-minute interval is allowed.


The following table lists the rate limits for the X API v2 Free access. These rate limits are also documented on each endpoint's API Reference page and also displayed in the developer portal's products section.


The following table lists the rate limits for the X API v2 Basic access. These rate limits are also documented on each endpoint's API Reference page and also displayed in the developer portal's products section.


The following table lists the rate limits for the X API v2 Pro access. These rate limits are also documented on each endpoint's API Reference page and also displayed in the developer portal's products section.


Users' rate limits are shared across all Apps that they have authorized. For example, if a specific user likes 20 Posts using one developer App and likes 20 Posts on a separate developer App within a 15 minute time period, the 40 requests would pull out of the same per user rate limit bucket. That means that if this endpoint has a user rate limit of 1,000 requests per 15 minutes, then this user would be able to like 960 more Posts within that 24 hour period of time across all X and third-party apps.


Note that the HTTP headers are contextual. When using application-only authentication, they indicate the rate limit for the application context. When using user-based authentication, they indicate the rate limit for that user context.




When these rate limits are exceeded, a 429 'Too many requests' error is returned from the endpoint. As discussed below, when rate limit errors occur, a best practice is to examine HTTP headers that indicate when the limit resets and pause requests until then.




When a "too many requests" or rate-limiting error occurs, the frequency of making requests needs to be slowed down. When a rate limit error is hit, the x-rate-limit-reset: HTTP header can be checked to learn when the rate-limiting will reset.




Another common pattern is based on exponential backoff, where the time between requests starts off small (for example, a few seconds), then doubled before each retry. This is continued until a request is successful, or some reasonable maximum time between requests is reached (for example, a few minutes).




Ideally, the client-side is self-aware of existing rate limits and can pause requests until the currently exceeded window expires. If you exceed a 15-minute limit, then waiting a minute or two before retrying makes sense.


Note that beyond these limits on the number of requests, the Standard Basic level of access provides up to 500,000 Posts per month from the recent search and filtered stream endpoints. If you have exceeded the monthly limit on the number of Posts, then it makes more sense for your app to raise a notification and know its enrollment day of the month and hold off requests until that day.




The tips below are there to help you code defensively and reduce the possibility of being rate limited. Some application features that you may want to provide are simply impossible in light of rate-limiting, especially around the freshness of results. If real-time information is an aim of your application, look into the filtered and sampled stream endpoints.




If your site keeps track of many X users (for example, fetching their current status or statistics about their X usage), consider only requesting data for users who have recently signed into your site.




If your application monitors a high volume of search terms, query less often for searches that have no results than for those that do. By using a back-off you can keep up to date on queries that are popular but not waste cycles requesting queries that very rarely change. Alternatively, consider using the filtered stream endpoint and filter with your search queries.




If an application abuses the rate limits, it will be denied. Denied apps are unable to get a response from the X API. If you or your application has been denied and you think there has been a mistake, you can use our Platform Support forms to request assistance. Please include the following information:


Prometheus provides a functional query language called PromQL (Prometheus QueryLanguage) that lets the user select and aggregate time series data in realtime. The result of an expression can either be shown as a graph, viewed astabular data in Prometheus's expression browser, or consumed by externalsystems via the HTTP API.


Depending on the use-case (e.g. when graphing vs. displaying the output of anexpression), only some of these types are legal as the result of auser-specified expression. For example, an expression that returns an instantvector is the only type which can be graphed.


PromQL follows the same escaping rules asGo. For string literals in single or double quotes, abackslash begins an escape sequence, which may be followed by a, b, f,n, r, t, v or \. Specific characters can be provided using octal(\nnn) or hexadecimal (\xnn, \unnnn and \Unnnnnnnn) notations.


Time series selectors are not to be confused with higher level concept of instant and range queries that can execute the time series selectors. A higher level instant query would evaluate the given selector at one point in time, however the range query would evaluate the selector at multiple different times in between a minimum and maximum timestamp at regular steps.


Instant vector selectors allow the selection of a set of time series and asingle sample value for each at a given timestamp (point in time). In the simplestform, only a metric name is specified, which results in an instant vectorcontaining elements for all time series that have this metric name.


Range vector literals work like instant vector literals, except that theyselect a range of samples back from the current instant. Syntactically, a timeduration is appended in square brackets ([]) at the end ofa vector selector to specify how far back in time values should be fetched foreach resulting range vector element. The range is a closed interval,i.e. samples with timestamps coinciding with either boundary of the range arestill included in the selection.


The @ modifier supports all representations of numeric literals described above.It works with the offset modifier where the offset is applied relative to the @modifier time. The results are the same irrespective of the order of the modifiers.


The timestamps at which to sample data, during a query, are selectedindependently of the actual present time series data. This is mainly to supportcases like aggregation (sum, avg, and so on), where multiple aggregatedtime series do not precisely align in time. Because of their independence,Prometheus needs to assign a value at those timestamps for each relevant timeseries. It does so by taking the newest sample before this timestamp within the lookback period.The lookback period is 5 minutes by default.


If a target scrape or rule evaluation no longer returns a sample for a timeseries that was previously present, this time series will be marked as stale.If a target is removed, the previously retrieved time series will be marked asstale soon after removal.


If a query is evaluated at a sampling timestamp after a time series is markedas stale, then no value is returned for that time series. If new samples aresubsequently ingested for that time series, they will be returned as expected.


A time series will go stale when it is no longer exported, or the target nolonger exists. Such time series will disappear from graphs at the times of their latest collected sample, and they will not be returnedin queries after they are marked stale.


Some exporters, which put their own timestamps on samples, get a different behaviour: series that stop being exported take the last value for (by default) 5 minutes beforedisappearing. The track_timestamps_staleness setting can change this.


If a query needs to operate on a substantial amount of data, graphing it mighttime out or overload the server or browser. Thus, when constructing queriesover unknown data, always start building the query in the tabular view ofPrometheus's expression browser until the result set seems reasonable(hundreds, not thousands, of time series at most). Only when you have filteredor aggregated your data sufficiently, switch to graph mode. If the expressionstill takes too long to graph ad-hoc, pre-record it via a recordingrule.


This is especially relevant for Prometheus's query language, where a baremetric name selector like api_http_requests_total could expand to thousandsof time series with different labels. Also, keep in mind that expressions thataggregate over many time series will generate load on the server even if theoutput is only a small number of time series. This is similar to how it wouldbe slow to sum all values of a column in a relational database, even if theoutput value is only a single number.


A relative time range is dependent on when the search is run. For example, a relative time range of -60m means 60 minutes ago. If the current time is 3 P.M., the search returns events from the last 60 minutes, or 2 P.M. to 3 P.M. today.




For example, if you specify a time range of Last 24 hours in the Time Range Picker and in the Search bar you specify earliest=-30m latest=now, the search only looks at events that have a timestamp within the last 30 minutes.


2. Specify the amount of time by using a number and a time unit. When you specify single time amounts, the number is implied. For example s is the same as 1s, m is the same as 1m, and so on. The supported time units are listed in the following table.

3a8082e126
Reply all
Reply to author
Forward
0 new messages